public static function tryFile($file) { if (DIRECTORY_SEPARATOR !== '/' || !function_exists('exec')) { return ''; } $type = @exec("file -b --mime-type " . escapeshellarg($file)); return $type ? $type : ''; }