public static function tryFinfo($file)
{
if (!function_exists('finfo_open')) {
return '';
}
$finfo = finfo_open(FILEINFO_MIME);
$type = finfo_file($finfo, $file);
finfo_close($finfo);
// Mimetype can come in text/plain; charset=us-ascii form
if (strpos($type, ';')) {
list($type, ) = explode(';', $type);
}
return $type;
}