class.upload.php is a powerful and mature PHP class to manage uploaded files, and manipulate images in many ways. The script is available under a GPL license.
more info about the class
$ file -b --mime foo.xlsx application/octet-stream; charset=binary $ file -b --mime bar.xlsx application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; charset=binary
I tried with two XLSX files on my system:
Here, even though they are two XLSX files, the MIME returned is not the same. So it seems that the file itself may confuse the MIME type detection.
I am not too sure that we can do something about that...