If your host still uses php 5.2 and does not have access to fileinfo functions, you can check the signature of the file header (magic numbers) to determine the mime type
function mimetype($data)
{
$Types = array(
"474946383761"=>"image/gif",
"474946383961"=>"image/gif",
"89504E470D0A1A0A"=>"image/png",
"FFD8FFE0"=>"image/jpeg",
"FFD8FFE1"=>"image/jpeg",
"FFD8FFE8"=>"image/jpeg",
"25504446"=>"application/pdf",
"377ABCAF271C"=>"application/zip",
"504B0304"=>"application/zip",
);
$Signature = substr($data,0,60);
$Signature = array_shift(unpack("H*",$Signature));
foreach($Types as $MagicNumber => $Mime)
{
if( stripos($Signature,$MagicNumber) === 0 )
return $Mime;
}
return "application/octet-stream";
}
. , , PK Zip 4 java- (.jar), foreach, mime, .
http://www.garykessler.net/library/file_sigs.html, - .