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

Chron's avatar
Level 6

What's the difference of mimes and mimetypes in validations?

I couldn't make the difference out of mimes and mimetypes

'photo' => 'mimetypes:image/png',
'photo' => 'mimes:png',

I have a photo.png file that I changed its extension to .mp4, and both of the validation accepted the file. Then, I tried an svg file with a png extension and both rejected it.

Since both of the rules read the file, what's the difference between the two and why should I use one than the other?

0 likes
2 replies
tykus's avatar

The difference is mimes takes a list of file extensions, whereas mimetypes takes a list of mimetypes. Under the hood, the logic defers to the same Mimetypes Symfony class to guess the mimetype from the uploaded file.

Chron's avatar
Level 6

@tykus I tried a file with jfif extension and both of these rules accepted it.

'photo' => 'mimetypes:image/jpeg',
'photo' => 'mimes:jpg

Basically, they're the same since both have the same functionality? The only difference is one takes file exts while the other takes mimetypes?

Please or to participate in this conversation.