PHP - finfo_file返回不正确的 MIME 类型


PHP - finfo_file returns incorrect MIME type

我有一个应用程序,我可以上传/下载不同格式的文件。当我上传时,我有正确的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类型是正确的。我必须做其他配置吗?有人可以帮我解决这个问题吗?

谢谢。

我这样做了,现在效果更好:

法典:

$finfo = finfo_open(FILEINFO_MIME, "conf/magic");
$myMime = finfo_file($finfo, $filename);

无论如何,谢谢。