Elgg\Filesystem\MimeTypeDetector::tryFinfo PHP Method

tryFinfo() public static method

Detect MIME type using finfo_open
public static tryFinfo ( string $file ) : string
$file string File path
return string Type detected. Empty string on failure
    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;
    }