Closed lettucebo closed 8 years ago
Mime types are unfortunately not 100% standard, even ones that are standard, not everyone follows the same standards. You can't assume that the mime type used in one place will match the exact mime type used elsewhere for the same files. Particularly look at the link you posted which shows some browsers using application/octet-stream
which is a generic catch-all mime-type for binary even though zip
is a well known file type.
Slightly better would be to check the file extension of the file uploaded, assuming it was provided. That should be .mp3
. It's not fully safe though.. the user could rename any file to .mp3
to upload so you need to be aware of that depending on what you're later doing with the file.
Best would be to validate the contents of the upload are in fact an .mp3
audio. Example: http://stackoverflow.com/questions/7302439/how-can-i-determine-that-a-particular-file-is-in-fact-an-mp3-file
Good luck.
Today I encounter a strange behavior about matching mp3 mime type with browser return ContentType
and I have search an article: Which mime type should I use for mp3
Found out that each browser return different ContentType
using chrome will not be able to upload mp3 file