我有一个应用程序,我可以上传/下载不同格式的文件。当我上传我有正确的MIME类型,但当我下载相同的文件时,PHP的finfo_file返回一个不正确的MIME类型。这是我得到的一些价值观:
代码:
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$mime_type = finfo_file($finfo, $filename);
echo $mime_type;
输出:
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
我检查了apache的mime.types文件,mime类型是正确的。我还有另一种配置吗?有人可以帮我解决这个问题吗?
感谢。
答案 0 :(得分:1)
我这样做了,现在效果更好:
代码:
$finfo = finfo_open(FILEINFO_MIME, "conf/magic");
$myMime = finfo_file($finfo, $filename);
非常感谢。