I’m working on an upload form in PHP that must allow only MP3 files.
When the upload is done, I analyze the file to check whether is it really an MP3. The first step is to detect the mime type as audio/mpeg
. I use the libraries finfo_file()
and works fine except that during the tests some MP3 files are rejected because their MIME type results as application/octet-stream
.
My questions are:
- Should my app definitely refuse those MP3 files? They actually play audio.
- Is there any reason why this MIME type is an MP3?
- is the detection of MIME type the most sure way to know the kind of file?