how to detect JFIF image type in laravel

1.5k Views Asked by At

I have laravel project that let user upload images and I can validate (jpeg/png) without problem. the problem occur when users upload JFIF-image (which consider to be images/jpeg mime types) but the laravel intervention package show message "Encoding format (jfif) is not supported." so, how to detect jfif during validation to prevent this. I tried:

$request->file('image')->extension() //return jpeg
1

There are 1 best solutions below

0
On

You should be able to get the extension using

$request->file('image')->getClientOriginalExtension()

Note that this function makes use of the pathinfo() function and so is based on the file name as per the comment on the source code