Download the PHP package bayfrontmedia/php-mime-types without Composer
On this page you can find all versions of the php package bayfrontmedia/php-mime-types. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download bayfrontmedia/php-mime-types
More information about bayfrontmedia/php-mime-types
Files in bayfrontmedia/php-mime-types
Package php-mime-types
Short Description Simple class used to detect the appropriate MIME type of a file based on it's extension.
License MIT
Homepage https://github.com/bayfrontmedia/php-mime-types
Informations about the package php-mime-types
PHP MIME types
Simple class used to detect appropriate MIME type.
This is by no means meant to handle an exhaustive list of every single MIME type, but rather focuses on the most common MIME types used.
Since MIME types will be detected using the file extension, some file extension related methods are available to use as well.
- License
- Author
- Requirements
- Installation
- Usage
License
This project is open source and available under the MIT License.
Author
Requirements
- PHP
^8.0
Installation
Usage
- getMimeTypes
- addMimeType
- getExtension
- hasExtension
- fromExtension
- fromFile
getMimeTypes
Description:
Return array of all MIME types.
Parameters:
- None
Returns:
- (array)
Example:
addMimeType
Description:
Adds new MIME type definitions.
Parameters:
$types
(array): Array whose keys are the file extension and values are the MIME type string
Returns:
- (void)
Example:
getExtension
Description:
Return extension of a given file, or empty string if not existing.
Parameters:
$file
(string)
Returns:
- (string)
Example:
hasExtension
Description:
Checks if a file has a given extension.
Parameters:
$extension
(string)$file
(string)
Returns:
- (bool)
Example:
fromExtension
Description:
Get MIME type from file extension.
Parameters:
$extension
(string)$default = 'application/octet-stream'
(string): Default MIME type to return if none found for given extension
Returns:
- (string)
Example:
fromFile
Description:
Get MIME type from file name.
Parameters:
$file
(string)$default = 'application/octet-stream'
(string): Default MIME type to return if none found for given extension
Returns:
- (string)
Example: