4

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.

M'Baku
  • 320
  • 4
  • 18
  • 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 Jan 16 '18 at 02:48
  • Possible duplicate of [Image upload not work laravel 5.4 doesn't get any error](https://stackoverflow.com/questions/45775532/image-upload-not-work-laravel-5-4-doesnt-get-any-error) – thechaoticpanda Jul 19 '18 at 14:47

1 Answers1

10

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

Sodik Abdullaev
  • 158
  • 4
  • 12