4
votes

For some reason my image validation refused to work on my laravel 5.5.28 application. It works perfectly on 5.4. I checked the documentation to see if there was a change in the documentation but there wasn't any.

Here is the validation logic for the image

'passport'=>'required|image|mimes:jpeg,png,jpg|max:1524',

HTML

<div class="form-group">
    <label>Upload a passport image</label>
    <input placeholder="upload passport" type="file" class="form-control" name="passport">
</div>

It returns both errors, image required and not png or jpeg etc... I have tried all to no avail.

Error messages

The passport must be an image. The passport must be a file of type: jpeg, png, jpg.

1
So I realized that why this was not working was because the image never uploads, because I didn't add the proper form attributes, I missed this enctype="multipart/form-data".M'Baku

1 Answers

10
votes

I found my mistake, that is why make sure you put on your form enctype="multipart/form-data" , and error fixed