get file mime type

@param stirng $path image file path

@return string
497021
public static function getType($path)
    {
        if (!is_file($path)) {
            throw new \InvalidArgumentException(sprintf('invalid filename or path "%s"', $path));
        }

        $info = (new \finfo(FILEINFO_MIME))->file($path);

        return substr($info, 0, strpos($info, ';'));
    }
561761
public static function getFile(string $path): string {
		$e = explode("/", rtrim($path, "/"));

		return $e[count($e) - 1];
	}
222943
protected function mimetype($path) {
		$type = '';
		
		if ($this->mimeDetect == 'finfo') {
			$type = @finfo_file($this->finfo, $path); 
		} elseif ($type == 'mime_content_type') {
			$type = mime_content_type($path);
		} else {
			$type = elFinderVolumeDriver::mimetypeInternalDetect($path);
		}
		
		$type = explode(';', $type);
		$type = trim($type[0]);
		
		if ($type == 'application/x-empty') {
			// finfo return this mime for empty files
			$type = 'text/plain';
		} elseif ($type == 'application/x-zip') {
			// http://elrte.org/redmine/issues/163
			$type = 'application/zip';
		}
		
		return $type == 'unknown' && $this->mimeDetect != 'internal'
			? elFinderVolumeDriver::mimetypeInternalDetect($path)
			: $type;
		
	}
793223
function filetype($path)
    {
        $type = $this->_get_stat_cache_prop($path, 'type');
        if ($type === false) {
            return false;
        }

        switch ($type) {
            case NET_SFTP_TYPE_BLOCK_DEVICE:
                return 'block';
            case NET_SFTP_TYPE_CHAR_DEVICE:
                return 'char';
            case NET_SFTP_TYPE_DIRECTORY:
                return 'dir';
            case NET_SFTP_TYPE_FIFO:
                return 'fifo';
            case NET_SFTP_TYPE_REGULAR:
                return 'file';
            case NET_SFTP_TYPE_SYMLINK:
                return 'link';
            default:
                return false;
        }
    }
653333
public static function getFileMimeByCmd($path)
    {
        if (empty($path) || ! is_file($path)) {
            return null;
        }
        
        $info = exec('file -ib "' . $path . '"');
        list ($type, $temp) = explode(';', $info);
        return $type;
    }
44152
public static function getMimeType($filePath)
    {
        $fInfo = finfo_open(FILEINFO_MIME_TYPE);
        $mime  = finfo_file($fInfo, $filePath);
        finfo_close($fInfo);

        return $mime;
    }
878869
static function GetFileSystemEntryType($path)
    {
        if (is_file($path))
            return FileSystemEntryType::File();
        else if (is_link($path))
            return FileSystemEntryType::Link();
        else if (is_dir($path))
            return FileSystemEntryType::Folder();
        else
            throw new Exceptions\PathNotFoundException("Path $path not found");
    }
541763
def get_mime(self, path, isdir):
        ''''''
        if isdir:
            file_type = FOLDER
        else:
            file_type = mimetypes.guess_type(path)[0]
            if not file_type:
                file_type = UNKNOWN
        return file_type
131130
private function getImageInfoFormatData( string $path ) : array
	{
		if( !file_exists( $path ) ){
			throw new \Exception( "该文件不存在" );
		}
		$data         = [
			// 纯名字
			'name' => '',
			// 相对路径
			'path' => '',
			// 文件字节
			'size' => 0,
			// 媒体类型
			'type' => '',
		];
		$data['name'] = $this->fileName;
		$data['path'] = $path;
		$data['size'] = filesize( $path );
		$data['type'] = $this->mediaType;
		return $data;
	}
569507
public static function mime($path)
    {
        $mime = false;

        if (is_readable($path)) {
            if (function_exists('finfo_open')) {
                $buffer = file_get_contents($path, false, null, -1, 5012);

                $finfo = finfo_open(FILEINFO_MIME_TYPE);
                $mime = finfo_buffer($finfo, $buffer);
                finfo_close($finfo);

                $buffer = null;
            } elseif (function_exists('mime_content_type')) {
                $mime = mime_content_type($path);
            }
        }

        if ($mime !== false && strpos($mime, 'application/') === 0) {
            $size = filesize($path);
            $mime = $size >= 0 && $size < 2 ? 'text/plain' : $mime;
        }

        return $mime;
    }
412893
public function get_extension($path){
        $type = $this->get_mime($path);
        $match = [];
        $ext = '';
        if( $type ){
            foreach( wp_get_mime_types() as $extensions => $content_type ){
                if( $content_type == $type ){
                    $ext = explode('|', $extensions)[0];
                    break;
                }
            }
        }
        return $ext;
    }
1148992
public function get(string $path): Image
    {
        $this->assertPresent($path);

        $image = new Image(
            $this->filesystem->read($path),
            $this->filesystem->getMimetype($path),
            $path
        );

        return $image;
    }
982116
public static function getDestinationFolder($path){
		$path = (string) $path;
		if( preg_match('/\.(jpe?g|gif|png|svg)$/i', $path) ) {
			return 'Image';
		}elseif( preg_match('/\.(otf|woff|ttf)$/i', $path) ) {
			return 'Font';
		}elseif( preg_match('/\.(css)$/i', $path) ) {
			return 'CSS';
		}elseif( preg_match('/\.(mp4|mp3)$/i', $path) ){
			return 'Media';
		}elseif( preg_match('/\.(smil|pls)$/i', $path) ){
			return 'Speech';
		}elseif( preg_match('/\.(js|json)$/i', $path) ){
			return 'JS';
		}elseif( preg_match('/\.x?html$/i', $path) ){
			return 'Text';
		}else{
			return 'Misc';
		}
	}
741868
public function type($path)
    {
        if ($this->isDirectory($path)) {
            return Filesystem::TYPE_DIR;
        }

        return $this->isFile($path) ?  Filesystem::TYPE_FILE : Filesystem::TYPE_UNKNOWN;
    }
758459
public function get_mime($file){
        $type = $this->get_content_type($file);
        if( $type ){
            $type = array_map('trim', explode(';', $type));
            return $type[0];
        }else{
            return '';
        }
    }
206615
public static function get($path)
    {
        $ext = strtolower(pathinfo($path, PATHINFO_EXTENSION));
        if (!isset(self::$fileTypes[$ext])) {
            return false;
        }
        return self::$fileTypes[$ext];
    }
693316
protected function getType($path)
    {
        if (Str::endsWith($path, Type::CSV)) {
            return Type::CSV;
        } elseif (Str::endsWith($path, Type::ODS)) {
            return Type::ODS;
        } else {
            return Type::XLSX;
        }
    }