public function getMimeType($path)
    {
        $mimeTypes = [
            'png'  => 'image/png',
            'jpe'  => 'image/jpeg',
            'jpeg' => 'image/jpeg',
            'jpg'  => 'image/jpeg',
            'gif'  => 'image/gif',
            'bmp'  => 'image/bmp',
            'ico'  => 'image/vnd.microsoft.icon',
            'tiff' => 'image/tiff',
            'tif'  => 'image/tiff',
            'svg'  => 'image/svg+xml',
            'svgz' => 'image/svg+xml',
        ];

        $ext = pathinfo($path, PATHINFO_EXTENSION);
        if (array_key_exists($ext, $mimeTypes)) {
            return $mimeTypes[$ext];
        }

        return null;
    }
public function getMimeType($path)
    {
        $mimeTypes = [
            'png'  => 'image/png',
            'jpe'  => 'image/jpeg',
            'jpeg' => 'image/jpeg',
            'jpg'  => 'image/jpeg',
            'gif'  => 'image/gif',
            'bmp'  => 'image/bmp',
            'ico'  => 'image/vnd.microsoft.icon',
            'tiff' => 'image/tiff',
            'tif'  => 'image/tiff',
            'svg'  => 'image/svg+xml',
            'svgz' => 'image/svg+xml',
        ];

        $ext = pathinfo($path, PATHINFO_EXTENSION);
        if (array_key_exists($ext, $mimeTypes)) {
            return $mimeTypes[$ext];
        }

        return null;
    }
public function getMimeType ( $ path ) { $ mimeTypes = [ 'png' => 'image/png' , 'jpe' => 'image/jpeg' , 'jpeg' => 'image/jpeg' , 'jpg' => 'image/jpeg' , 'gif' => 'image/gif' , 'bmp' => 'image/bmp' , 'ico' => 'image/vnd.microsoft.icon' , 'tiff' => 'image/tiff' , 'tif' => 'image/tiff' , 'svg' => 'image/svg+xml' , 'svgz' => 'image/svg+xml' , ] ; $ ext = pathinfo ( $ path , PATHINFO_EXTENSION ) ; if ( array_key_exists ( $ ext , $ mimeTypes ) ) { return $ mimeTypes [ $ ext ] ; } return null ; }
Guess mime type based on file extension
@param  string $path
@return string|null
Guess mime type based on file extension