(lol sorry, I realized that this was asked a few months ago when I was finishing ... well, maybe also add this ...)
If it is a * nix server, you can use the file command.
file -bi <filepath>
You will need to use "exec" in PHP to do this, I think? I am new to PHP, so don't quote me on this, but ...
$content_type = exec("file -bi " . escapeshellarg($filepath));
I have not tested it, so you may need to avoid the path line and format the output.
I do not know if it will be more reliable than other methods.
EMPraptor
source share