获取Microsoft 10 Edge浏览器Mime类型的php [英] Getting Microsoft 10 Edge browser Mime Types php

查看:288
本文介绍了获取Microsoft 10 Edge浏览器Mime类型的php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当检查在Microsoft 10的Edge浏览器中上载的文件的mime类型时,我得到.doc文件的这种Mime类型:

When checking the file mime types of files being uploaded in Microsoft 10's Edge browser, I get this Mime Type for .doc files:

application/octet-stream

显然,这表示任意二进制数据":

Apparently this indicates "arbitrary binary data": Do I need Content-Type: application/octet-stream for file download?

在其他浏览器上,我得到application/msword

On other browsers I get application/msword

是否为Edge浏览器的.doc文件提供了一种处理mime类型的新方法,也许还有我需要注意的其他mime类型?

Is there a new way mime types are handled for .doc files for the Edge browser, and maybe other mime types I need to be aware of?

更新:

我正在使用php的$_FILES['uploadName']['type']

推荐答案

我发现,通过使用它,我得到了正确的mime类型:

I found that by using this instead, I get the correct mime type:

$finfo = new finfo(FILEINFO_MIME_TYPE);
$mimeType = $finfo->file($_FILES['uploadName']['tmp_name'][$key]);

正如马丁在上面的评论中所述:

And as Martin mentioned in a comment above:

您不应从$ _FILE中提供的数据中获取MIME类型,如下所示: 这是非常片状的,可以解释,因为你是 体验.相反,请对上传的临时文件进行新的分析 文件,请使用finfo()或类似的文件.

You should not grab the MIME type from the data given in $_FILE as this is extremely flaky and up for interpretation, as you are experiencing. Instead, do a new analysis of the uploaded temporary file, Use finfo() or similar.

这篇关于获取Microsoft 10 Edge浏览器Mime类型的php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆