You can easily rename a file (such as a .exe) to a .jpg, and the mime type identifier passed by the browser will be wrong.
Instead, trust a Unix shell tool called "file".
<?
$allowed=array(
'PHP script text',
'ASCII text',
'JPEG image data');
$fname=escapeshellarg($_FILE[varname][tmp_name]);
$type=file $fname;
foreach($allowed as $allow)
if (stristr($type, $allow)!==false)
{
// It's an acceptable type - move on!
}
?>
the "file" shell command will accept whatever type of file and completely disregards the name of the file, mime-type, or anything else. This provides a much greater degree of trustability.