lino's avatar
Level 1

Validation error is not showing on array of file

Hi, I'm having problem of showing the error with an array of file.

The html is like this

<input type="file" name="images[]">
<input type="file" name="images[]">
.
.
<input type="file" name="images[]">

The Form Request

'images.*' => 'mimes:jpeg',
'name' => 'required',

When the file type is not jpeg, it redirect back to the input page. So the validation works, but there's not error message. When I checked the error message bag, it is empty.

Illuminate\Support\ViewErrorBag Object ( [bags:protected] => Array ( ) ) 

I've tried creating rules for individual field from here: https://laracasts.com/discuss/channels/general-discussion/calling-standard-validation-rules-from-a-custom-validation-rule

But it's still not working..

0 likes
2 replies
bobbybouwmann's avatar

I don't think it works with the file tag. You can retrieve multiple files like so, not sure on how to handle this validation!

<input type="file" name="images" multiple>

Please or to participate in this conversation.