finfo返回了错误的类型

时间:2013-07-25 09:07:21

标签: php

$finfo = new finfo(FILEINFO_MIME_TYPE);
echo $finfo->file($file)

它给出了:

for .msg:CDF V2 Document,corrupt:无法阅读摘要信息

表示.doc:application / vnd.ms-excel

表示.docx:application / zip

...

/opt/xampp/etc/mime.types看起来不错

任何想法?

1 个答案:

答案 0 :(得分:1)

正如AmazingDreams所说,这些是zip文件中的openxml。如果你解压缩,它只会告诉你它是一个XML。

您可以将类型添加到htaccess文件中,以便apache可以识别它们......只需将这些行添加到您网站根目录中的htaccess文件中:

AddType application/vnd.ms-word.document.macroEnabled.12 .docm
AddType application/vnd.openxmlformats-officedocument.wordprocessingml.document docx
AddType application/vnd.openxmlformats-officedocument.wordprocessingml.template dotx
AddType application/vnd.ms-powerpoint.template.macroEnabled.12 potm
AddType application/vnd.openxmlformats-officedocument.presentationml.template potx
AddType application/vnd.ms-powerpoint.addin.macroEnabled.12 ppam
AddType application/vnd.ms-powerpoint.slideshow.macroEnabled.12 ppsm
AddType application/vnd.openxmlformats-officedocument.presentationml.slideshow ppsx
AddType application/vnd.ms-powerpoint.presentation.macroEnabled.12 pptm
AddType application/vnd.openxmlformats-officedocument.presentationml.presentation pptx
AddType application/vnd.ms-excel.addin.macroEnabled.12 xlam
AddType application/vnd.ms-excel.sheet.binary.macroEnabled.12 xlsb
AddType application/vnd.ms-excel.sheet.macroEnabled.12 xlsm
AddType application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx
AddType application/vnd.ms-excel.template.macroEnabled.12 xltm
AddType application/vnd.openxmlformats-officedocument.spreadsheetml.template xltx

有关该主题的讨论,请参阅here