public static function guessType($file_path, $reference_name = null, $default = 'application/octet-stream') {
		if (!$reference_name) {
			$reference_name = basename($file_path);
		}

		$extension = pathinfo($reference_name, PATHINFO_EXTENSION);
		if ($extension and $mime_type = static::getTypeForExtension($extension)) {
			return $mime_type;
		}

		// While it's true that the extension doesn't determine the type,
		// only use finfo as a fallback because it's bad at detecting text
		// types like CSS and JavaScript.
		if ($mime_type = static::getMagicType($file_path)) {
			return $mime_type;
		}

		return $default;
	}
public static function guessType($file_path, $reference_name = null, $default = 'application/octet-stream') {
		if (!$reference_name) {
			$reference_name = basename($file_path);
		}

		$extension = pathinfo($reference_name, PATHINFO_EXTENSION);
		if ($extension and $mime_type = static::getTypeForExtension($extension)) {
			return $mime_type;
		}

		// While it's true that the extension doesn't determine the type,
		// only use finfo as a fallback because it's bad at detecting text
		// types like CSS and JavaScript.
		if ($mime_type = static::getMagicType($file_path)) {
			return $mime_type;
		}

		return $default;
	}
public static function guessType ( $ file_path , $ reference_name = null , $ default = 'application/octet-stream' ) { if ( ! $ reference_name ) { $ reference_name = basename ( $ file_path ) ; } $ extension = pathinfo ( $ reference_name , PATHINFO_EXTENSION ) ; if ( $ extension and $ mime_type = static :: getTypeForExtension ( $ extension ) ) { return $ mime_type ; } // While it's true that the extension doesn't determine the type, // only use finfo as a fallback because it's bad at detecting text // types like CSS and JavaScript. if ( $ mime_type = static :: getMagicType ( $ file_path ) ) { return $ mime_type ; } return $ default ; }
Guess the MIME type of a given file, first by checking the extension then by falling back to magic.

@param string $file_path Relative or absolute path to an existing file.
@param string $reference_name Use this name for detection based on the extension.
@param string $default Default MIME type.

@return string|null The associated MIME type or the default if none found.
Guess the MIME type of a given file first by checking the extension then by falling back to magic .