Thursday, May 2, 2024
 Popular · Latest · Hot · Upcoming
7
rated 0 times [  7] [ 0]  / answers: 1 / hits: 5873  / 3 Years ago, sun, november 21, 2021, 8:35:54

Hi I am trying to work out why PHP is returning an 'msword' file type when it should be 'excel' so have tested on my Ubuntu box using both the 'file' and 'mimetype' commands. As you can see from the results below they return different results. Can anybody explain why?



root@dev:~# file --mime-type 1.xls
1.xls: application/msword
root@dev:~# mimetype 1.xls
1.xls: application/vnd.ms-excel


I should also note the file in question is returning 'msword' on a Windows Server. It was generated using PHPExcel.



Thanks for your help.


More From » mime-type

 Answers
4

file gets its results from /etc/mime.types.



From there:




application/mathematica-old
application/ms-tnef
application/msaccess mdb
application/msword doc dot
application/news-message-id
application/news-transmission
application/ocsp-request
application/ocsp-response





mimetype gets it from ...



ENVIRONMENT

XDG_DATA_HOME
XDG_DATA_DIRS
These variables can list base directories to search for data files.
The shared mime-info will be expected in the "mime" sub directory
of one of these directories. If these are not set, there will be
searched for the following directories:

$HOME/.local/share/mime
/usr/local/share/mime
/usr/share/mime

See also the "XDG Base Directory Specification"
http://freedesktop.org/Standards/basedir-spec
<http://freedesktop.org/Standards/basedir-spec>


Worth noting is this part in the man page for mimetype:




For naming switches I followed the manpage of file(1) version 4.02 when possible. They seem to differ completely from the spec in the 'utilities' chapter of IEEE Std 1003.1-2001 (POSIX).




So you might call it a bug against file /etc/mime.types since vnd.ms-excel is more accurate.


[#31818] Tuesday, November 23, 2021, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
amacal

Total Points: 457
Total Questions: 102
Total Answers: 116

Location: Thailand
Member since Thu, Apr 22, 2021
3 Years ago
;