php - finfo_file() returns wrong mime type for some images? -
I allow the image upload on my website and I need to get the file type to upload the file so that I can see Can I see what type is in the whitelist and is allowed to upload.
I'm using it using Try the above code on the above image and say that the mime type is Why the Alternatively, you can use the finfo_file () , but it does not work in all cases. Here's my code:
// mime type get $ finfo = finfo_open (FILEINFO_MIME_TYPE); $ Mime = finfo_file ($ finfo, $ filePath); Echo $ mime;
application / octet-stream when it is Clearly a JPG file.
financefolder () is not working with the test image? Whatever problem can I fix so that I can get the file type correctly?
exif_imagetype () with
image_type_to_mime_type () can also be used. Example:
function get_mime ($ url) {$ image_type = exif_imagetype ($ url); Return image_type_to_mime_type ($ image_type); } Echo get_mime ('http://ecx.images-amazon.com/images/I/41q8koaxM0L.jpg'); // image / jpeg
Comments
Post a Comment