Support Home Page › Forums › Joomla Software › Easy File Uploader Module › Error with MIME types? › Re: Error with MIME types?

@dbn. Thanks for posting. OK. I reviewed the code you posted. However, I am confused about something. The code you posted is different from the code in Easy File Uploader version 2.7.8.
This is the code you posted:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
// try to use recommended functions<br /> if (defined('FILEINFO_MIME') &&<br /> function_exists('finfo_open') && is_callable('finfo_open') &&<br /> function_exists('finfo_file') && is_callable('finfo_file') &&<br /> function_exists('finfo_close') && is_callable('finfo_close'))<br /> {<br /> $finfo = finfo_open(FILEINFO_MIME);<br /> $mime = finfo_file($finfo, $file);<br /> if ($mime === '')<br /> {<br /> $mime = false;<br /> }<br /> finfo_close($finfo);<br /> } |
However, the code in my class, modEasyFileUploaderHelper in the helper.php file from lines 201 to 214 is:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
// try to use recommended functions<br /> if (defined('FILEINFO_MIME_TYPE') &&<br /> function_exists('finfo_open') && is_callable('finfo_open') &&<br /> function_exists('finfo_file') && is_callable('finfo_file') &&<br /> function_exists('finfo_close') && is_callable('finfo_close'))<br /> {<br /> $finfo = finfo_open(FILEINFO_MIME_TYPE);<br /> $mime = finfo_file($finfo, $file);<br /> if ($mime === '')<br /> {<br /> $mime = false;<br /> }<br /> finfo_close($finfo);<br /> } |
Notice that the constant in your code listing for finfo_open is “FILEINFO_MIME”, where as the constant in my code on line 207 is “FILEINFO_MIME_TYPE”. This makes a big difference, since the constant FILEINFO_MIME will give you the mime and the encoding charset, and FILEINFO_MIME_TYPE will only give you the mime without the encoding charset.
So the question is why is your code of my extension different from my code on my extension? Did you change that constant?
If you notice I already have code to remove the charset from the exec and shell_exec options to detect the MIME. However, because of the constant I use for finfo_open, there is no need for that code snippet you added to remove the charset.
You should reinstall version 2.7.8 of the Easy File Uploader.
So, to answer your question, “Can anyone confirm that the MIME type comparison code in Easy File Uploader 2.7.8 is written to expect the inclusion of the charset information?”… Yes, the MIME type comparison code in Easy File Uploader 2.7.8 is indeed written to expect the inclusion of the charset information. However, for some reason, unknown to me, your code is not the same as the officially published code.
Can you please confirm whether you have edited the constant applied to the finfo_open function and changed it from FILEINFO_MIME_TYPE to FILEINFO_MIME?