Getting Microsoft 10 Edge browser Mime Types php

耗尽温柔 提交于 2019-12-23 10:10:03

问题


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?

On other browsers I get application/msword

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?

Update:

I was grabbing the mime type using php's $_FILES['uploadName']['type']


回答1:


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:

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.



来源:https://stackoverflow.com/questions/32829814/getting-microsoft-10-edge-browser-mime-types-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!