chris15001900's avatar

5.0 Image upload issue

I'm using dev-develop version for my new project and I cannot solve an issue with uploading image. I have a standard form with image field:

{!! Form::file('image') !!}

and form opening with 'files' set to true. When I'm not using new FormRequest method injection or remove file field everything works fine. However when image field is present and I don't select any file (no validation rule is set for image field) I get following error:

InvalidArgumentException
An uploaded file must be an array or an instance of UploadedFile.

And when I select a file I get another error:

Exception
Serialization of 'Symfony\Component\HttpFoundation\File\UploadedFile' is not allowed

Does anyone know if I'm doing sth wrong or is it due to L5 being still in development?

0 likes
12 replies
pmall's avatar

I can't figure out how to solve the first problem too. But for the second question, you have to add a protected $dontFlash array as attribute of your FormRequest class containing the name of your file input field. protected $dontFlash = ['image']. This way the image input is not passed back when the validation fails.

I hope anyone has a solution for the first problem.

fraserk's avatar

Did you get this resolved. I'm having the exact issue.

chris15001900's avatar

The serialization problem seems to be solved. However the first issue still exists

thomaskim's avatar

I got the same problem. When I do upload an image, it works fine. When I don't upload an image, I get that error message.

thomaskim's avatar
Level 41

The most recent update seems to have fixed the problem for me.

NormySan's avatar

Yep, Taylor fixed this yesterday! Was having the same problem too :)

mcamara's avatar

Does anybody have this error again? I have laravel 5.0 updated to its last development version and this problem has came back. Any thoughts?

chris15001900's avatar

I'm using

$dontFlash = ['image'];

in form requests to avoid seriaization however when I don't select any file this issue still comes up:

An uploaded file must be an array or an instance of UploadedFile.

Right now I'm just wating for 5.0 release because there's nothing I found to repair this

Please or to participate in this conversation.