1
我有一個應用程序,我可以上傳/下載不同格式的文件。當我上傳我有正確的MIME類型,但是當我下載相同的文件時,PHP的finfo_file返回給我一個不正確的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類型是正確的。是否有另一種配置,我必須做的?有人可以幫我解決這個問題嗎?
謝謝。
FWIW,有些格式不能與其他格式區分開來。 CSV也是一個完全有效的「文本/純文本」,沒有技術上的差異。 *根據定義,檢測*類型是不準確的科學。 – deceze
當我下載一個.csv文件時,用Bloc筆記打開它並不符合人體工程學。默認情況下,所選的應用程序必須是Excel才能讀取它,並且對於PowerPoint演示文稿,它應該是ms PowerPoint不是ms字。我的意思是,那就是我想要的。 – cglvli