I created a function to check the file extension of and imported Excel file. I have run same source on 2 different PCs.
PC-1 Configuration:
PC-2 Configuration:
My Excel file was created by Google Spreadsheet and exported as an MS Office file with extension .xlsx.
In PC-1, when I debug the $_FILES['file']['type'];
value I get the extension:
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
Yet on PC-2, I received:
'application/octet-stream'
My question is: Why with same source, same import file, just different environments, does the debug output show a different file extension? Is the cause installing MS Office?
MIME types are defined by three attributes: language (lang), encoding (enc), and content-type (type). At least one of these attributes must be present for each type. The most commonly used attribute is type. The server frequently considers the type when deciding how to generate the response to the client.
To Solve MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled ErrorJust make Sure Your File name and the name You are Using in Link Tag Both Are Same. For Example my File name is style.
Multiple MIME types can use one extension. For example, if your organization uses multiple versions of a program, you can define a MIME type for each version; however, file names of all versions use the same extension.
A browser usually identifies a resource's MIME type by observing the Content-Type response header in an HTTP response. Sometimes, developers set values for Content-Type headers that are not appropriate for the response's content.
It's because Microsoft office isn't installed on PC 2.
So it Chrome doesn't know how to interpret.
Octet-stream is a last ditch attempt to interpret.
This post goes into more detail and there's a way you can tweak registry to perhaps achieve same result.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With