src/Control/HTTP.php
public static function get_mime_type($filename)
    {
        // If the finfo module is compiled into PHP, use it.
        $path = BASE_PATH . DIRECTORY_SEPARATOR . $filename;
        if (class_exists('finfo') && file_exists($path)) {
            $finfo = new finfo(FILEINFO_MIME_TYPE);
            return $finfo->file($path);
        }

        // Fallback to use the list from the HTTP.yml configuration and rely on the file extension
        // to get the file mime-type
        $ext = strtolower(File::get_file_extension($filename));
        // Get the mime-types
        $mimeTypes = HTTP::config()->uninherited('MimeTypes');

        // The mime type doesn't exist
        if (!isset($mimeTypes[$ext])) {
            return 'application/unknown';
        }

        return $mimeTypes[$ext];
    }
public static function get_mime_type($filename)
    {
        // If the finfo module is compiled into PHP, use it.
        $path = BASE_PATH . DIRECTORY_SEPARATOR . $filename;
        if (class_exists('finfo') && file_exists($path)) {
            $finfo = new finfo(FILEINFO_MIME_TYPE);
            return $finfo->file($path);
        }

        // Fallback to use the list from the HTTP.yml configuration and rely on the file extension
        // to get the file mime-type
        $ext = strtolower(File::get_file_extension($filename));
        // Get the mime-types
        $mimeTypes = HTTP::config()->uninherited('MimeTypes');

        // The mime type doesn't exist
        if (!isset($mimeTypes[$ext])) {
            return 'application/unknown';
        }

        return $mimeTypes[$ext];
    }
public static function get_mime_type ( $ filename ) { // If the finfo module is compiled into PHP, use it. $ path = BASE_PATH . DIRECTORY_SEPARATOR . $ filename ; if ( class_exists ( 'finfo' ) && file_exists ( $ path ) ) { $ finfo = new finfo ( FILEINFO_MIME_TYPE ) ; return $ finfo -> file ( $ path ) ; } // Fallback to use the list from the HTTP.yml configuration and rely on the file extension // to get the file mime-type $ ext = strtolower ( File :: get_file_extension ( $ filename ) ) ; // Get the mime-types $ mimeTypes = HTTP :: config ( ) -> uninherited ( 'MimeTypes' ) ; // The mime type doesn't exist if ( ! isset ( $ mimeTypes [ $ ext ] ) ) { return 'application/unknown' ; } return $ mimeTypes [ $ ext ] ; }
Get the MIME type based on a file's extension. If the finfo class exists in PHP, and the file
exists relative to the project root, then use that extension, otherwise fallback to a list of
commonly known MIME types.

@param string $filename
@return string
Get the MIME type based on a file s extension . If the finfo class exists in PHP and the file exists relative to the project root then use that extension otherwise fallback to a list of commonly known MIME types .