Reputation: 137
I have an application which i can upload/download files with different format. When i upload i have the correct MIME type, but when i download the same file, finfo_file of PHP returns me an incorrect MIME type. Here is some values that i got :
Code :
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$mime_type = finfo_file($finfo, $filename);
echo $mime_type;
Output :
application/msword // test0.pot INCORRECT should be application/vnd.ms-powerpoint
text/plain // test1.csv ICNORRECT should be text/csv
application/vnd.ms-powerpoint // test2.pptx INCORRECT should be application/vnd.openxmlformats-officedocument.presentationml.presentation
application/msword // test3.pps INCORRECT should be application/vnd.ms-powerpoint
application/msword // test4.docx INCORRECT should be application/vnd.openxmlformats-officedocument.wordprocessingml.document
application/msword // test5.doc CORRECT
application/vnd.ms-excel // test6.xls CORRECT
application/vnd.ms-excel // test7.xlsx INCORRECT should be application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
application/msword // test8.docm INCORRECT should be application/vnd.ms-word.document.macroenabled.12
application/pdf // test9.pdf CORRECT
I checked apache's mime.types file, mime types are correct. Is there an another configuration that i have to do ? Can someone help me to fix this ?
Thanks.
Upvotes: 2
Views: 3177
Reputation: 137
I did this and it works better now :
Code :
$finfo = finfo_open(FILEINFO_MIME, "conf/magic");
$myMime = finfo_file($finfo, $filename);
Thanks anyway.
Upvotes: 2