Hello,
Today I am facing a very strange problem while I was just checking mime-type for uploaded files by my app users in PHP.
But it seems, none of the popular PHP functions are working.
Here it is I tried already.
// Solution # 1
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$mtype = finfo_file($finfo, $tmpFile);
finfo_close($finfo);
if ($mtype == ("application/msword") ||
$mtype == ("application/vnd.openxmlformats-officedocument.wordprocessingml.document") ||
$mtype == ("application/pdf")
) {
return true;
} else {
return false;
}
//Solution # 2
$mimeArray = array(
'application/msword',
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'application/pdf'
);
$mime = mime_content_type($tmpFile);
if (!in_array($mime, $mimeArray)) {
return false;
} else {
return true;
}
finfo_file, finfo_open, mime_content_type none of these functions are working. So for PHP application running on GAE standard environment, what's the most safest and easiest ways to detect file's mime-type in PHP?
Thanks in advance.
Regards,
Shaharia Azam