sleiman.sleiman's avatar

Laravel 5 File Upload with form request Issue

I am receiving this error each time I submit a file:

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

I have the following request


<?php namespace MyApp\Http\Requests\Tracks; use Illuminate\Foundation\Http\FormRequest; class StoreTrackRequest extends FormRequest { /** * Get the validation rules that apply to the request. * * @return array */ public function rules() { return [ 'name'=>'required|min:3', 'artist_id'=>'required', 'audio'=>'required|mimes:mp3', ]; } /** * Determine if the user is authorized to make this request. * * @return bool */ public function authorize() { return true; } }

NB: when I remove the request everything works fine

0 likes
7 replies
pmall's avatar

That was an old error removed with a update of the framework. Try composer update but expect many other bug with your actual code

danielwinter's avatar

Hey have you figured this out? I'm having the same problem. And yes, I am at the latest version of both framework and app hierarchy.

sleiman.sleiman's avatar

Im not sure that its a valid solution but when I remove 'required' from the file rules its seems to work.

chris15001900's avatar

Did you try adding

$dontFlash = [ 'file' ];

to your request class?

PatrickBauer's avatar

Not yet, but you're right that should be a possible solution. But only temporary, I think there should be an automatic way to include file fields

Please or to participate in this conversation.