15 [__CLASS__,
'tryFinfo'],
16 [__CLASS__,
'tryMimeContentType'],
17 [__CLASS__,
'tryFile'],
18 [__CLASS__,
'tryGetimagesize'],
30 'txt' =>
'text/plain',
32 'html' =>
'text/html',
35 'js' =>
'application/javascript',
36 'json' =>
'application/json',
37 'xml' =>
'application/xml',
38 'swf' =>
'application/x-shockwave-flash',
39 'flv' =>
'video/x-flv',
43 'jpe' =>
'image/jpeg',
44 'jpeg' =>
'image/jpeg',
45 'jpg' =>
'image/jpeg',
48 'ico' =>
'image/vnd.microsoft.icon',
49 'tiff' =>
'image/tiff',
50 'tif' =>
'image/tiff',
51 'svg' =>
'image/svg+xml',
52 'svgz' =>
'image/svg+xml',
55 'zip' =>
'application/zip',
56 'rar' =>
'application/x-rar-compressed',
57 'exe' =>
'application/x-msdownload',
58 'msi' =>
'application/x-msdownload',
59 'cab' =>
'application/vnd.ms-cab-compressed',
62 'mp3' =>
'audio/mpeg',
63 'qt' =>
'video/quicktime',
64 'mov' =>
'video/quicktime',
67 'pdf' =>
'application/pdf',
68 'psd' =>
'image/vnd.adobe.photoshop',
69 'ai' =>
'application/postscript',
70 'eps' =>
'application/postscript',
71 'ps' =>
'application/postscript',
74 'odt' =>
'application/vnd.oasis.opendocument.text',
75 'ods' =>
'application/vnd.oasis.opendocument.spreadsheet',
78 'doc' =>
'application/msword',
79 'rtf' =>
'application/rtf',
80 'xls' =>
'application/vnd.ms-excel',
81 'ppt' =>
'application/vnd.ms-powerpoint',
82 'docx' =>
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
83 'docm' =>
'application/vnd.ms-word.document.macroEnabled.12',
84 'dotx' =>
'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
85 'dotm' =>
'application/vnd.ms-word.template.macroEnabled.12',
86 'xlsx' =>
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
87 'xlsm' =>
'application/vnd.ms-excel.sheet.macroEnabled.12',
88 'xltx' =>
'application/vnd.openxmlformats-officedocument.spreadsheetml.template',
89 'xltm' =>
'application/vnd.ms-excel.template.macroEnabled.12',
90 'xlsb' =>
'application/vnd.ms-excel.sheet.binary.macroEnabled.12',
91 'xlam' =>
'application/vnd.ms-excel.addin.macroEnabled.12',
92 'pptx' =>
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
93 'pptm' =>
'application/vnd.ms-powerpoint.presentation.macroEnabled.12',
94 'ppsx' =>
'application/vnd.openxmlformats-officedocument.presentationml.slideshow',
95 'ppsm' =>
'application/vnd.ms-powerpoint.slideshow.macroEnabled.12',
96 'potx' =>
'application/vnd.openxmlformats-officedocument.presentationml.template',
97 'potm' =>
'application/vnd.ms-powerpoint.template.macroEnabled.12',
98 'ppam' =>
'application/vnd.ms-powerpoint.addin.macroEnabled.12',
99 'sldx' =>
'application/vnd.openxmlformats-officedocument.presentationml.slide',
100 'sldm' =>
'application/vnd.ms-powerpoint.slide.macroEnabled.12',
101 'one' =>
'application/msonenote',
102 'onetoc2' =>
'application/msonenote',
103 'onetmp' =>
'application/msonenote',
104 'onepkg' =>
'application/msonenote',
105 'thmx' =>
'application/vnd.ms-officetheme',
121 $ext = pathinfo(
$file, PATHINFO_EXTENSION);
129 if ($this->use_extension && isset($this->
extensions[$ext])) {
144 foreach ($this->strategies as $strategy) {
161 if (
$type ===
'application/zip') {
165 return "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
167 return "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
169 return "application/vnd.openxmlformats-officedocument.presentationml.presentation";
175 return "application/vnd.ms-powerpoint";
193 if (!function_exists(
'finfo_open')) {
197 $finfo = finfo_open(FILEINFO_MIME);
201 if (strpos(
$type,
';')) {
214 return function_exists(
'mime_content_type') ? mime_content_type(
$file) :
'';
224 if (DIRECTORY_SEPARATOR !==
'/' || !function_exists(
'exec')) {
227 $type = @exec(
"file -b --mime-type " . escapeshellarg(
$file));
239 return empty(
$data[
'mime']) ?
'' :
$data[
'mime'];
static tryGetimagesize($file)
Detect MIME type.
if(!array_key_exists($filename, $text_files)) $file
tryStrategies($file)
Detect MIME type using various strategies.
static tryFinfo($file)
Detect MIME type using finfo_open.
if(elgg_trigger_plugin_hook('usersettings:save', 'user', $hooks_params, true)) foreach($request->validation() ->all() as $item) $data
getType($file, $default=self::DEFAULT_TYPE)
Sniff the MIME type.
fixDetectionErrors($type, $extension)
Fix common type detection errors.
static tryMimeContentType($file)
Detect MIME type using mime_content_type.
Detect the MIME type of a file.
static tryFile($file)
Detect MIME type using file(1)