public static function getTypeFromFile(string $path): string
    {
        if (!is_file($path) || !is_readable($path)) {
            throw new \InvalidArgumentException(
                "invalid value provided for 'path'; ".
                "expecting an absolute path to a readable file"
            );
        }

        $finfo = new \finfo(FILEINFO_MIME_TYPE);
        $type = @$finfo->file($path);
        return ($type === false) ? "application/octet-stream" : $type;
    }
public static function getTypeFromFile(string $path): string
    {
        if (!is_file($path) || !is_readable($path)) {
            throw new \InvalidArgumentException(
                "invalid value provided for 'path'; ".
                "expecting an absolute path to a readable file"
            );
        }

        $finfo = new \finfo(FILEINFO_MIME_TYPE);
        $type = @$finfo->file($path);
        return ($type === false) ? "application/octet-stream" : $type;
    }
public static function getTypeFromFile ( string $ path ) : string { if ( ! is_file ( $ path ) || ! is_readable ( $ path ) ) { throw new \ InvalidArgumentException ( "invalid value provided for 'path'; " . "expecting an absolute path to a readable file" ) ; } $ finfo = new \ finfo ( FILEINFO_MIME_TYPE ) ; $ type = @ $ finfo -> file ( $ path ) ; return ( $ type === false ) ? "application/octet-stream" : $ type ; }
Get a content type from file contents

@param string $path The absolute patht the file to examine
@return string
Get a content type from file contents