Returns the results of the mime type check either as a boolean or an
array of boolean values.

@param string|array $filename The file path whose type to test.
@param string|array $mimeType The mime type to test against.
@return boolean|array
345054
public function isMimeType($filename, $mimeType)
    {
        if (is_array($filename)) {
            $result = array();
            foreach ($filename as $key => $value) {
                $result[] = ($this->getMimeType($value) == (is_array($mimeType) ? $mimeType[$key] : $mimeType))
                            ? true
                            : false;
            }
            return $result;
        } else {
            return $this->getMimeType($filename) == $mimeType ? true : false;
        }
    }
636340
protected static function _findMimeType($mimeType) {
        if ($mimeType instanceof File) {
            $mimeType = $mimeType->type();

        } else if (strpos($mimeType, '/') === false) {
            $mimeType = self::getTypeFromExt($mimeType);
        }

        return $mimeType;
    }
992657
public function getMimetype()
    {
        if (isset($this->mimetype) === false) {
            $finfo = new \finfo(FILEINFO_MIME);
            $mimetype = $finfo->file($this->getPathname());
            $mimetypeParts = preg_split('/\s*[;,]\s*/', $mimetype);
            $this->mimetype = strtolower($mimetypeParts[0]);
            unset($finfo);
        }

        return $this->mimetype;
    }
627409
public static function mimeContentType($filename) {
        static $mime_types = [
            'html'    => 'text/html;charset=UTF-8',
            'htm'     => 'text/html;charset=UTF-8',
            'shtml'   => 'text/html;charset=UTF-8',
            'css'     => 'text/css',
            'xml'     => 'text/xml',
            'gif'     => 'image/gif',
            'jpeg'    => 'image/jpeg',
            'jpg'     => 'image/jpeg',
            'js'      => 'application/javascript',
            'atom'    => 'application/atom+xml',
            'rss'     => 'application/rss+xml',
            'mml'     => 'text/mathml',
            'txt'     => 'text/plain;charset=UTF-8',
            'jad'     => 'text/vnd.sun.j2me.app-descriptor',
            'wml'     => 'text/vnd.wap.wml',
            'htc'     => 'text/x-component',
            'png'     => 'image/png',
            'svg'     => 'image/svg+xml',
            'svgz'    => 'image/svg+xml',
            'tif'     => 'image/tiff',
            'tiff'    => 'image/tiff',
            'wbmp'    => 'image/vnd.wap.wbmp',
            'webp'    => 'image/webp',
            'ico'     => 'image/x-icon',
            'jng'     => 'image/x-jng',
            'bmp'     => 'image/x-ms-bmp',
            'woff'    => 'font/woff',
            'woff2'   => 'font/woff2',
            'jar'     => 'application/java-archive',
            'war'     => 'application/java-archive',
            'ear'     => 'application/java-archive',
            'json'    => 'application/json',
            'hqx'     => 'application/mac-binhex40',
            'doc'     => 'application/msword',
            'pdf'     => 'application/pdf',
            'ps'      => 'application/postscript',
            'eps'     => 'application/postscript',
            'ai'      => 'application/postscript',
            'rtf'     => 'application/rtf',
            'm3u8'    => 'application/vnd.apple.mpegurl',
            'kml'     => 'application/vnd.google-earth.kml+xml',
            'kmz'     => 'application/vnd.google-earth.kmz',
            'xls'     => 'application/vnd.ms-excel',
            'eot'     => 'application/vnd.ms-fontobject',
            'ppt'     => 'application/vnd.ms-powerpoint',
            'odg'     => 'application/vnd.oasis.opendocument.graphics',
            'odp'     => 'application/vnd.oasis.opendocument.presentation',
            'ods'     => 'application/vnd.oasis.opendocument.spreadsheet',
            'odt'     => 'application/vnd.oasis.opendocument.text',
            'pptx'    => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
            'xlsx'    => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
            'docx'    => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
            'wmlc'    => 'application/vnd.wap.wmlc',
            '7z'      => 'application/x-7z-compressed',
            'cco'     => 'application/x-cocoa',
            'jardiff' => 'application/x-java-archive-diff',
            'jnlp'    => 'application/x-java-jnlp-file',
            'run'     => 'application/x-makeself',
            'pl'      => 'application/x-perl',
            'pm'      => 'application/x-perl',
            'prc'     => 'application/x-pilot',
            'pdb'     => 'application/x-pilot',
            'rar'     => 'application/x-rar-compressed',
            'rpm'     => 'application/x-redhat-package-manager',
            'sea'     => 'application/x-sea',
            'swf'     => 'application/x-shockwave-flash',
            'sit'     => 'application/x-stuffit',
            'tcl'     => 'application/x-tcl',
            'tk'      => 'application/x-tcl',
            'der'     => 'application/x-x509-ca-cert',
            'pem'     => 'application/x-x509-ca-cert',
            'crt'     => 'application/x-x509-ca-cert',
            'xpi'     => 'application/x-xpinstall',
            'xhtml'   => 'application/xhtml+xml;charset=UTF-8',
            'xspf'    => 'application/xspf+xml',
            'zip'     => 'application/zip',
            'bin'     => 'application/octet-stream',
            'exe'     => 'application/octet-stream',
            'dll'     => 'application/octet-stream',
            'deb'     => 'application/octet-stream',
            'dmg'     => 'application/octet-stream',
            'iso'     => 'application/octet-stream',
            'img'     => 'application/octet-stream',
            'msi'     => 'application/octet-stream',
            'msp'     => 'application/octet-stream',
            'msm'     => 'application/octet-stream',
            'mid'     => 'audio/midi',
            'midi'    => 'audio/midi',
            'kar'     => 'audio/midi',
            'mp3'     => 'audio/mpeg',
            'ogg'     => 'audio/ogg',
            'm4a'     => 'audio/x-m4a',
            'ra'      => 'audio/x-realaudio',
            '3gpp'    => 'video/3gpp',
            '3gp'     => 'video/3gpp',
            'ts'      => 'video/mp2t',
            'mp4'     => 'video/mp4',
            'mpeg'    => 'video/mpeg',
            'mpg'     => 'video/mpeg',
            'mov'     => 'video/quicktime',
            'webm'    => 'video/webm',
            'flv'     => 'video/x-flv',
            'm4v'     => 'video/x-m4v',
            'mng'     => 'video/x-mng',
            'asx'     => 'video/x-ms-asf',
            'asf'     => 'video/x-ms-asf',
            'wmv'     => 'video/x-ms-wmv',
            'avi'     => 'video/x-msvideo'
        ];
        $chks = explode('.', $filename);
        $ext  = strtolower(array_pop($chks));
        if (array_key_exists($ext, $mime_types)) {
            return $mime_types[ $ext ];
        } else if (is_file($filename) && function_exists('finfo_open')) {
            $finfo    = finfo_open(FILEINFO_MIME);
            $mimetype = finfo_file($finfo, $filename);
            finfo_close($finfo);

            return $mimetype;
        } else {
            return 'application/octet-stream';
        }
    }
1094670
public function isType(
        array $mimeTypes,
        bool $allowUnverified = false
    ): bool
    {
        $contentType = $this->getContentType($allowUnverified);
        foreach ($mimeTypes as $type) {
            if (strtolower($type) === $contentType) {
                return true;
            }
        }
        return false;
    }
1308842
public static function getMimeType($filename)
	{
		$mime_types = static::getMimeTypes();
		
		$extension = pathinfo($filename, PATHINFO_EXTENSION);
    	$extension = strtolower($extension);
    	
		if (array_key_exists($extension, $mime_types)) {
            return $mime_types[$extension];
        } elseif (function_exists('finfo_open')) {
            $finfo = finfo_open(FILEINFO_MIME);
            $mimetype = finfo_file($finfo, $filename);
            finfo_close($finfo);
            return $mimetype;
        } 
        return 'application/octet-stream';
	}
636141
static public function getMimeType($contentType, $filename=null)
    {
        if ($contentType = strtolower($contentType)) {
            if (strpos($contentType, '/') !== false) {
                $mimeTypes = array_keys(self::$mime_types, $contentType);
                $ext = $filename ? pathinfo($filename, PATHINFO_EXTENSION) : null;
                
                if (count($mimeTypes) === 1) {
                    return $mimeTypes[0];
                } elseif (count($mimeTypes) > 1) {
                    return $ext && in_array($ext, $mimeTypes) ? $ext : $mimeTypes[0];
                } else {
                    return $ext ? static::getMimeType($ext) : null;
                }
            } else {
                $ext = pathinfo($contentType, PATHINFO_EXTENSION);
                if (isset(static::$mime_types[$ext])) {
                    return $ext;
                }
            }
        } elseif ($filename) {
            return static::getMimeType($filename);
        }
        
        return null;
    }
448913
public function uploadFiles(string $filename, string $mimetype = '', string $postname = '') {

        $this->params = array_merge($this->params, $this->file($filename, $mimetype, $postname));

        return $this->header(['Content-Type' => 'multipart/form-data']);

    }
1218939
private static function getMimeType($filePath)
    {
        $currentErrorReporting = \error_reporting();
        \error_reporting(0);

        $mimeType = '';
        $fileInfo = \finfo_open(FILEINFO_MIME_TYPE);
        if (false !== $fileInfo) {
            $mimeType = (string) \finfo_file($fileInfo, $filePath);
            \finfo_close($fileInfo);
        }
        \error_reporting($currentErrorReporting);

        return $mimeType;
    }
966254
public static function isImage($mimeType)
    {
        if (in_array($mimeType, self::$mimeTypes, true)) {
            return (bool)preg_match('|^image/.+$|', $mimeType);
        }

        return false;
    }
208968
public function classFor(string $mimeType)
    {
        if ($this->provideClass($mimeType)) {
            return $this->mimeTypeClasses[$mimeType];
        }

        return null;
    }
459896
static public function guessByMimeType($mimeType)
    {
        switch (substr($mimeType, 0, strpos($mimeType, '/'))) {
            case 'audio' : return self::AUDIO; break;
            case 'image' : return self::IMAGE; break;
            case 'video' : return self::VIDEO; break;
        }

        if (preg_match('~zip|rar|compress~', $mimeType)) {
            return self::ARCHIVE;
        }

        if ($mimeType === 'application/x-shockwave-flash') {
            return self::FLASH;
        }

        return self::FILE;
    }
18185
private function getExtension($mimetype) {
		if(preg_match('/^(image|audio|video)\/(.+)$/', $mimetype, $matches)) {
			$extension = $matches[2];
			if(in_array($extension, ['jpeg', 'pjpeg'])) {
				$extension = 'jpg';
			} else if(in_array($extension, ['mpeg4'])) {
				$extension = 'mp4';
			}

			return $extension;
		}

		return null;
	}
1114309
public static function getFileMimeType($file)
    {
        $finfo = finfo_open(FILEINFO_MIME_TYPE);
        if ($finfo) {
            $mime_type = finfo_file($finfo, $file);
            finfo_close($finfo);
            return $mime_type;
        }
        return false;
    }
1372610
protected function _getMime($filename, $default = 'application/octet-stream') {
		if (!isset($this->_Mime)) {
			$this->_Mime = new Mime();
		}
		$mime = $this->_Mime->detectMimeType($filename);
		// Some environments falsely return the default too fast, better fallback to extension here
		if (!$mime || $mime === $default) {
			$ext = pathinfo($filename, PATHINFO_EXTENSION);
			$mime = $this->_Mime->getMimeTypeByAlias($ext);
		}
		return $mime;
	}
1180997
public function mime()
    {
        if (!$this->exists()) {
            return false;
        }
        if (class_exists('finfo')) {
            $finfo = new finfo(FILEINFO_MIME);
            $type = $finfo->file($this->pwd());
            if (!$type) {
                return false;
            }
            list($type) = explode(';', $type);

            return $type;
        }
        if (function_exists('mime_content_type')) {
            return mime_content_type($this->pwd());
        }

        return false;
    }
52725
public static function guessMimeType($filename, $default = 'application/octed-stream')
    {
        $guesser = new FileExtMimeTypeGuesser();

        $mime = $guesser->guess($filename);
        if (null === $mime) {
            try {
                $mime = MimeTypeGuesser::getInstance()->guess($filename);
            } catch (FileNotFoundException $ex) {
                // dont care
            }
        }

        return null === $mime ? $default : $mime;
    }