Function __global->get_mime_type
Definitions
sources/mime_types.php
- Find the mime type for the given file extension. It does not take into account whether the file type has been safelisted or not, and returns a binary download mime type for any unknown extensions.
- Visibility: public
- Is abstract?: No
- Is static?: No
- Is final?: No
- Returns: string
Parameters
| Name | Type | Passed by reference? | Variadic? | Default | Set | Range | Description |
|---|---|---|---|---|---|---|---|
| $extension | string | No | No | required parameter | N/A | N/A | The file extension (no dot) |
| $as_admin | boolean | No | No | required parameter | N/A | N/A | Whether there are admin privileges, to render dangerous media types (client-side risk only) |
Returns
- The MIME type
- Type: string
- Set: N/A
- Range: N/A
Preview
Code (PHP)
/**
* Find the mime type for the given file extension. It does not take into account whether the file type has been safelisted or not, and returns a binary download mime type for any unknown extensions.
*
* @param string $extension The file extension (no dot)
* @param boolean $as_admin Whether there are admin privileges, to render dangerous media types (client-side risk only)
* @return string The MIME type
*/
function get_mime_type(string $extension, bool $as_admin) : string
* Find the mime type for the given file extension. It does not take into account whether the file type has been safelisted or not, and returns a binary download mime type for any unknown extensions.
*
* @param string $extension The file extension (no dot)
* @param boolean $as_admin Whether there are admin privileges, to render dangerous media types (client-side risk only)
* @return string The MIME type
*/
function get_mime_type(string $extension, bool $as_admin) : string
