Call to undefined function mime_content_type()

I get a Call to undefined function mime_content_type() and after lookign around the net I found that this is deprecated and I should now use fileinfo.

I need help converting my code to the new standard. If I do that will the new standard work on the old servers?

Can anyone help me?

[php]function isImage($file) {
//image file types (extenstion => mime type)
$types = array(
‘png’ => ‘image/png’,
‘jpe’ => ‘image/jpeg’,
‘jpeg’ => ‘image/jpeg’,
‘jpg’ => ‘image/jpeg’,
‘gif’ => ‘image/gif’,
‘bmp’ => ‘image/bmp’,
‘ico’ => ‘image/vnd.microsoft.icon’,
‘tiff’ => ‘image/tiff’,
‘tif’ => ‘image/tiff’,
‘svg’ => ‘image/svg+xml’,
‘svgz’ => ‘image/svg+xml’,
);
$ext = substr(strrchr($file, ‘.’),1);
if (in_array($ext, array_keys($types)) && in_array(mime_content_type($file), $types)) {
return true;
}
return false;
}[/php]

Even that mime_content_type() is depricated, it is still supported in PHP starting from 4.3 versions. If you want to switch to using PECL fileinfo functions instead, make sure you have PHP 5.3 and fileinfo php extension is installed on your server.

Sponsor our Newsletter | Privacy Policy | Terms of Service