Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wrong type returned by finfo

Tags:

php

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

it gives :

for .msg : CDF V2 Document, corrupt: Cannot read summary info

for .doc : application/vnd.ms-excel

for .docx : application/zip

...

/opt/xampp/etc/mime.types looks good

any idea ?

like image 446
Ben Avatar asked Nov 13 '22 01:11

Ben


1 Answers

As AmazingDreams said, these are openxml in zip files. If you unzip, it will simply tell you it is an XML.

You could addtype to the htaccess files so that apache can recognize them... Just add these lines to your htaccess file in the root of your website:

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

See here for a discussion on the topic.

like image 128
Terry Avatar answered Nov 14 '22 22:11

Terry