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

Ligonsker's avatar

Should I validate both mimetype and mime extension?

Hello,

Should I validate both mimetype and the file extension? I want to allow users to upload only photos and videos.

At first I thought that if I only validate mime by extension a user would be able to simply change a pdf extension to png and he would pass validation but I checked and it doesn't work, it also finds out if it's not an actual mime type of the extension

So would that be enough to only validate by extension or I still want both?

ty

0 likes
1 reply
jlrdw's avatar

That's up to you and if only images are allowed.

Please or to participate in this conversation.