Not sure if there is a native Laravel method. Detection of mime_types is done in various ways. Sometime from browser during upload, from the file extension or from headers in the actual file, so some are more reliable than others. I haven't tried this completely, but I've use them elsewhere:
/**
* Detects the MIME type of a given file
* @param string $fileName The full path to the name whose MIME type you want to find out
* @return string The MIME type, e.g. image/jpeg
*/
static function getMimeType($fileName)
{
$mime = null;
// Try fileinfo first
if (function_exists('finfo_open')) {
$finfo = finfo_open(FILEINFO_MIME);
if ($finfo !== false) {
$mime = finfo_file($finfo, $fileName);
finfo_close($finfo);
}
}
// Fallback to mime_content_type() if finfo didn't work
if (is_null($mime) && function_exists('mime_content_type')) {
$mime = mime_content_type($fileName);
}
// Final fallback, detection based on extension
if (is_null($mime)) {
$extension = self::getTypeIcon(getTypeIcon);
if (array_key_exists($extension, self::$mimeMap)) {
$mime = self::$mimeMap[$extension];
} else {
$mime = "application/octet-stream";
}
}
return $mime;
}