Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ReakyMark's avatar

Laravel mimes validate not fully working. Pleaes help

it weird to me. when my validate is ....|mimes:jpeg,jpg,png,gif, I had 2 main file for test: test.htm and test.jpg so i copy test.jpg and rename their extension.

Final file i had

test.html    (html file)
test.jpg       (image file)
test.asd      (image file)

if i upload test.html yes it error wrong mimes. Ok

if i upload image file i copy before and rename their extension to asd. test.asd my validate mimies stop working it let this file pass. what wrong in this ? No error mimes given and pass

Please help Thank in advance.

0 likes
7 replies
lostdreamer_nl's avatar

"I copy before and rename their extension to asd"

So it's still an image.... It just has a wrong extension...... That does not change it's mime type.

Try and upload a real txt file or something....

CorCronje's avatar

It may be that your OS is hiding the actual file extension, I've seen it happen on Windows when you rename a file the file explorer actually hide the actual file extension so you may end up with "test.asd.jpg" instead of the intended "test.asd".

You can also supplement your validation logic with the mimestype rule ('mimetypes:image/jpeg') for additional confidence that the file under validation is really an image.

newbie360's avatar

rename the file.extension, but it is still image

dd(mime_content_type('......./test.jpg'));
dd(mime_content_type('......./test.asd'));

both are the same mime type: "image/jpeg"

Tray2's avatar

Yes the mime and the extension has nothing to do with eachother.

ReakyMark's avatar

@CronjeCor i have try |mimetypes:image/jpeg,image/jpg it still the same.maybe i have to add custom code to my upload function else my DB will be broken :D

lostdreamer_nl's avatar

@ReakyMark Is the file you are trying to upload actually an image which you just renamed to some other extension?

I believe it is.

If so: It's mime type is still image/jpg

Try uploading a real txt file for instance, and you'll see that it will fail the mimetype validation.

Please or to participate in this conversation.