获取 Microsoft 10 Edge 浏览器 Mime 类型 php

Getting Microsoft 10 Edge browser Mime Types php

在 Microsoft 10 的 Edge 浏览器中检查上传文件的 MIME 类型时,我得到 .doc 个文件的 MIME 类型:

application/octet-stream

显然这表明 "arbitrary binary data":Do I need Content-Type: application/octet-stream for file download?

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

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

更新:

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

获取 mime 类型

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

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

正如马丁在上面的评论中提到的那样:

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.