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.

2
  • 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". Commented Jan 16, 2018 at 2:48
  • Possible duplicate of Image upload not work laravel 5.4 doesn't get any error Commented Jul 19, 2018 at 14:47

1 Answer 1

10

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.