首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >“'file -mime-type”和“mimetype”命令返回不同的结果

“'file -mime-type”和“mimetype”命令返回不同的结果
EN

Ask Ubuntu用户
提问于 2013-04-10 12:55:11
回答 2查看 5.8K关注 0票数 9

嗨,我想弄清楚为什么PHP会返回一个‘m刀’文件类型,而它应该是'excel‘,所以已经使用' file’和'mimetype‘命令在我的Ubuntu框上进行了测试。从下面的结果可以看出,它们返回不同的结果。有人能解释原因吗?

代码语言:javascript
复制
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生成的。

谢谢你的帮助。

EN

回答 2

Ask Ubuntu用户

发布于 2013-04-10 13:19:03

用于.deb包的两个工具之间也有类似的区别。

文件似乎使用/etc/mime.types,而mimetype使用更多XDG_DATA_DIRS (来自man mimetypes)的复杂混合:

代码语言:javascript
复制
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.
票数 5
EN

Ask Ubuntu用户

发布于 2013-08-23 14:05:01

我花了一段时间才找到它,但我能够在debian上安装mimetype。

代码语言:javascript
复制
sudo apt-get install libfile-mimeinfo-perl

现在,我将application/vnd.ms-excel作为.xls而不是application/msword

票数 1
EN
页面原文内容由Ask Ubuntu提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://askubuntu.com/questions/279899

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档