5

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']

Community
  • 1
  • 1
Andrew
  • 18,680
  • 13
  • 103
  • 118
  • smells like a bug - how about reporting it –  Sep 28 '15 at 19:26
  • 2
    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. – Martin Sep 28 '15 at 20:22

1 Answers1

4

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.

Andrew
  • 18,680
  • 13
  • 103
  • 118
  • I should have read your answer before my comment above, oh well.... Glad you found the more reliable way of doing it – Martin Sep 28 '15 at 20:23
  • Yea thanks it's a good comment and worth people seeing if they ever come here, I will add to my answer. – Andrew Sep 29 '15 at 03:40