[英]getting different mime type for exe file in php
I am trying to get mime type of an exe file in PHP.我正在尝试在 PHP 中获取 exe 文件的 mime 类型。 It's returning
application/x-dosexec
.它正在返回
application/x-dosexec
。 but the mime type of an exe file should be application/x-msdownload
.但是 exe 文件的 mime 类型应该是
application/x-msdownload
。
I am checking with a temporary file name($file_tmp_name)
, using the code below:我正在使用以下代码检查临时文件
name($file_tmp_name)
:
$finfo = finfo_open(FILEINFO_MIME_TYPE);
echo finfo_file($finfo, $file_tmp_name);
finfo_close($finfo);
application/x-dosexec
is actually a subtype of application/x-msdownload
, specifically having the .exe
glob. application/x-dosexec
实际上是的子类型application/x-msdownload
,具体地具有.exe
水珠。
You don't need to check for all possible mime types, just check if it belongs to the parent executable mime type.您不需要检查所有可能的 mime 类型,只需检查它是否属于父可执行 mime 类型。 See how it's done with mediatype here .
在此处了解如何使用 mediatype 完成此操作。
Ref: Summary of application/x-dosexec from webarchive.org.uk参考: 来自 webarchive.org.uk 的 application/x-dosexec 摘要
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.