I remember there was some bug with L5 and image uploads I don't know if they are solved
Nov 26, 2014
2
Level 23
L5 File Validation Issues
Ok, not me, file validation via FormRequest not working properly. 'Required' works fine, but max: , image, mime, etc. either don't execute or if they do they don't generate a Session error. Example, if I add mimes:jpeg,bmp,png,gif it will fail if it is not an image and just do a redirect back with no error messages in session. I've tried single, multi file upload. Also, attempted to messages() and none.
That said, if I remove validation I am getting the files and can save etc. as well do manual validation.
A fresh L5. Struggling with file validation via Form. I'm uploading multiple files Without the validation I can get and save files, but with request in place it is blocking any rule.
{!! Form::file('files[]', [
'class' => 'mme-toolbar-top-action-btn blue',
'file-input' => '"files"',
'multiple' => true
])
!!}
Class ImageRequest extends Request {
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'files' => 'required | mimes:jpeg,bmp,png,gi'
];
}
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
}
public function messages()
{
return [
'files.required' => 'Please attach a valid file before upload.',
'files.mime' => 'Mime issue.'
];
}
Please or to participate in this conversation.