Detect the MIME type of a file.
More...
Detect the MIME type of a file.
Definition at line 7 of file MimeTypeDetector.php.
◆ fixDetectionErrors()
Elgg\Filesystem\MimeTypeDetector::fixDetectionErrors |
( |
|
$type, |
|
|
|
$extension |
|
) |
| |
Fix common type detection errors.
- Parameters
-
string | $type | MIME type detected |
string | $extension | Filename extensions |
- Returns
- string Fixed MIME type
Definition at line 160 of file MimeTypeDetector.php.
◆ getType()
Elgg\Filesystem\MimeTypeDetector::getType |
( |
|
$file, |
|
|
|
$default = self::DEFAULT_TYPE |
|
) |
| |
Sniff the MIME type.
- Parameters
-
string | $file | File path |
string | $default | Default type to return on failure |
- Returns
- string MIME type
Definition at line 115 of file MimeTypeDetector.php.
◆ tryFile()
static Elgg\Filesystem\MimeTypeDetector::tryFile |
( |
|
$file | ) |
|
|
static |
Detect MIME type using file(1)
- Parameters
-
- Returns
- string Type detected. Empty string on failure
Definition at line 223 of file MimeTypeDetector.php.
◆ tryFinfo()
static Elgg\Filesystem\MimeTypeDetector::tryFinfo |
( |
|
$file | ) |
|
|
static |
Detect MIME type using finfo_open.
- Parameters
-
- Returns
- string Type detected. Empty string on failure
Definition at line 192 of file MimeTypeDetector.php.
◆ tryGetimagesize()
static Elgg\Filesystem\MimeTypeDetector::tryGetimagesize |
( |
|
$file | ) |
|
|
static |
Detect MIME type.
- Parameters
-
- Returns
- string Type detected. Empty string on failure
Definition at line 237 of file MimeTypeDetector.php.
◆ tryMimeContentType()
static Elgg\Filesystem\MimeTypeDetector::tryMimeContentType |
( |
|
$file | ) |
|
|
static |
Detect MIME type using mime_content_type.
- Parameters
-
- Returns
- string Type detected. Empty string on failure
Definition at line 213 of file MimeTypeDetector.php.
◆ tryStrategies()
Elgg\Filesystem\MimeTypeDetector::tryStrategies |
( |
|
$file | ) |
|
Detect MIME type using various strategies.
- Parameters
-
- Returns
- string Type detected. Empty string on failure
Definition at line 142 of file MimeTypeDetector.php.
◆ $extensions
Elgg\Filesystem\MimeTypeDetector::$extensions |
◆ $strategies
Elgg\Filesystem\MimeTypeDetector::$strategies |
Initial value:= [
[__CLASS__, 'tryFinfo'],
[__CLASS__, 'tryMimeContentType'],
[__CLASS__, 'tryFile'],
[__CLASS__, 'tryGetimagesize'],
]
Definition at line 14 of file MimeTypeDetector.php.
◆ $use_extension
Elgg\Filesystem\MimeTypeDetector::$use_extension = true |
◆ DEFAULT_TYPE
const Elgg\Filesystem\MimeTypeDetector::DEFAULT_TYPE = 'application/octet-stream' |
The documentation for this class was generated from the following file: