嗨,我想弄清楚为什么PHP会返回一个‘m刀’文件类型,而它应该是'excel‘,所以已经使用' file’和'mimetype‘命令在我的Ubuntu框上进行了测试。从下面的结果可以看出,它们返回不同的结果。有人能解释原因吗?
root@dev:~# file --mime-type 1.xls
1.xls: application/msword
root@dev:~# mimetype 1.xls
1.xls: application/vnd.ms-excel我还应该注意到,所讨论的文件是在Windows上返回“m刀”。它是使用PHPExcel生成的。
谢谢你的帮助。
发布于 2013-04-10 13:19:03
用于.deb包的两个工具之间也有类似的区别。
文件似乎使用/etc/mime.types,而mimetype使用更多XDG_DATA_DIRS (来自man mimetypes)的复杂混合:
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>
FILES
The base dir for all data files is determined by two environment variables, see "ENVIRONMENT".
BASE/mime/packages/SOURCE.xml
All other files are compiled from these source files. To re-compile them use update-mime-database(1).
BASE/mime/globs
Compiled information about globs.
BASE/mime/magic
Compiled information about magic numbers.
BASE/mime/MEDIA/SUBTYPE.xml
Descriptions of a mimetype in multiple languages, used for the "--describe" switch.发布于 2013-08-23 14:05:01
我花了一段时间才找到它,但我能够在debian上安装mimetype。
sudo apt-get install libfile-mimeinfo-perl现在,我将application/vnd.ms-excel作为.xls而不是application/msword。
https://askubuntu.com/questions/279899
复制相似问题