public static function mimeType($check, $mimeTypes = [])
    {
        $file = static::getFilename($check);
        if ($file === false) {
            return false;
        }

        if (!function_exists('finfo_open')) {
            throw new LogicException('ext/fileinfo is required for validating file mime types');
        }

        if (!is_file($file)) {
            throw new RuntimeException('Cannot validate mimetype for a missing file');
        }

        $finfo = finfo_open(FILEINFO_MIME);
        $finfo = finfo_file($finfo, $file);

        if (!$finfo) {
            throw new RuntimeException('Can not determine the mimetype.');
        }

        list($mime) = explode(';', $finfo);

        if (is_string($mimeTypes)) {
            return self::_check($mime, $mimeTypes);
        }

        foreach ($mimeTypes as $key => $val) {
            $mimeTypes[$key] = strtolower($val);
        }

        return in_array($mime, $mimeTypes);
    }
public static function mimeType($check, $mimeTypes = [])
    {
        $file = static::getFilename($check);
        if ($file === false) {
            return false;
        }

        if (!function_exists('finfo_open')) {
            throw new LogicException('ext/fileinfo is required for validating file mime types');
        }

        if (!is_file($file)) {
            throw new RuntimeException('Cannot validate mimetype for a missing file');
        }

        $finfo = finfo_open(FILEINFO_MIME);
        $finfo = finfo_file($finfo, $file);

        if (!$finfo) {
            throw new RuntimeException('Can not determine the mimetype.');
        }

        list($mime) = explode(';', $finfo);

        if (is_string($mimeTypes)) {
            return self::_check($mime, $mimeTypes);
        }

        foreach ($mimeTypes as $key => $val) {
            $mimeTypes[$key] = strtolower($val);
        }

        return in_array($mime, $mimeTypes);
    }
public static function mimeType ( $ check , $ mimeTypes = [ ] ) { $ file = static :: getFilename ( $ check ) ; if ( $ file === false ) { return false ; } if ( ! function_exists ( 'finfo_open' ) ) { throw new LogicException ( 'ext/fileinfo is required for validating file mime types' ) ; } if ( ! is_file ( $ file ) ) { throw new RuntimeException ( 'Cannot validate mimetype for a missing file' ) ; } $ finfo = finfo_open ( FILEINFO_MIME ) ; $ finfo = finfo_file ( $ finfo , $ file ) ; if ( ! $ finfo ) { throw new RuntimeException ( 'Can not determine the mimetype.' ) ; } list ( $ mime ) = explode ( ';' , $ finfo ) ; if ( is_string ( $ mimeTypes ) ) { return self :: _check ( $ mime , $ mimeTypes ) ; } foreach ( $ mimeTypes as $ key => $ val ) { $ mimeTypes [ $ key ] = strtolower ( $ val ) ; } return in_array ( $ mime , $ mimeTypes ) ; }
Checks the mime type of a file.

Will check the mimetype of files/UploadedFileInterface instances
by checking the using finfo on the file, not relying on the content-type
sent by the client.

@param string|array|\Psr\Http\Message\UploadedFileInterface $check Value to check.
@param array|string $mimeTypes Array of mime types or regex pattern to check.
@return bool Success
@throws \RuntimeException when mime type can not be determined.
@throws \LogicException when ext/fileinfo is missing
Checks the mime type of a file .