0

Background: I have created a test class, which worked fine in laravel 5.1; but doesn't in laravel 5.2. This is because the "test" parameter for the file is lost.

I use a code below to create file request:

$this->dataFile = new \Symfony\Component\HttpFoundation\File\UploadedFile(
    base_path('tests/files/datafiles/A.csv'), 'A.csv', 'text/csv', 13071, null, true
);

and I send it using $this->call()

$this->call('POST', '/uploadFile?token=' . $this->token, $params, [], ['file' => [$this->dataFile]], []);

The problem that I am having is that on receiving end the "test" parameters comes through us being false:

[0] => Illuminate\Http\UploadedFile Object
        (
            [test:Symfony\Component\HttpFoundation\File\UploadedFile:private] =>
            [originalName:Symfony\Component\HttpFoundation\File\UploadedFile:private] => A.csv
            [mimeType:Symfony\Component\HttpFoundation\File\UploadedFile:private] => text/csv
            [size:Symfony\Component\HttpFoundation\File\UploadedFile:private] => 13071
            [error:Symfony\Component\HttpFoundation\File\UploadedFile:private] => 0
            [pathName:SplFileInfo:private] => D:\tests/files/datafiles/A.csv
            [fileName:SplFileInfo:private] => A.csv
        )

1 Answer 1

1

You should use:

\Illuminate\Http\UploadedFile

To create the uploaded file instead of:

\Symfony\Component\HttpFoundation\File\UploadedFile

See this answer for more details: https://stackoverflow.com/a/37306881/1835484

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.