Where are you getting hold of the file? If it's though an http url you should be able to pick up the mime type from the header. If it's a file on your filesystem, you can use [man]fstat()[/man] to get a load of statistics about the file and if you're on a *nix server you could use
$file_info=shell_exec("file ".$file);
echo($info);
You'll have to do a little playing around with the returned string to get the exact info you want. Also, it won't recognise that a file ending in .php is a php script (which is correct, because it may well not be, it may be one of files concerning my Pimple Homing Project 😉) it will just say it's ASCII text to resolve known extensions to file types you're going to have to define that yourself I believe.
HTH
Bubble