$mimes) { foreach ($mimes as $mime) { if (!strncasecmp($type, $mime, strlen($type))) return $extension; } } return null; } /** * The default MIME type for unknown extensions. */ protected const DEFAULT_TYPE = 'application/octet-stream'; /** * The list of known MIME types. */ protected const TYPES = array( // Text-based document formats. 'html' => ['text/html'], 'htm' => ['text/html'], 'shtml' => ['text/html'], 'txt' => ['text/plain'], 'text' => ['text/plain'], 'log' => ['text/plain'], 'md' => ['text/markdown'], 'markdown' => ['text/markdown'], 'rtf' => ['text/rtf'], 'xml' => ['text/xml'], 'xsl' => ['text/xml'], 'css' => ['text/css'], 'csv' => ['text/csv'], // Binary document formats. 'doc' => ['application/msword'], 'dot' => ['application/msword'], 'xls' => ['application/vnd.ms-excel'], 'ppt' => ['application/vnd.ms-powerpoint'], 'docx' => ['application/vnd.openxmlformats-officedocument.wordprocessingml.document'], 'dotx' => ['application/vnd.openxmlformats-officedocument.wordprocessingml.document'], 'xlsx' => ['application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'], 'pptx' => ['application/vnd.openxmlformats-officedocument.presentationml.presentation'], 'odt' => ['application/vnd.oasis.opendocument.text'], 'ods' => ['application/vnd.oasis.opendocument.spreadsheet'], 'odp' => ['application/vnd.oasis.opendocument.presentation'], 'odg' => ['application/vnd.oasis.opendocument.graphics'], 'odb' => ['application/vnd.oasis.opendocument.database'], 'pdf' => ['application/pdf'], 'dvi' => ['application/x-dvi'], // Images. 'bmp' => ['image/bmp'], 'gif' => ['image/gif'], 'jpg' => ['image/jpeg'], 'jpeg' => ['image/jpeg'], 'jpe' => ['image/jpeg'], 'jfif' => ['image/jpeg'], 'png' => ['image/png'], 'webp' => ['image/webp'], 'svg' => ['image/svg+xml'], 'tiff' => ['image/tiff'], 'tif' => ['image/tiff'], 'ico' => ['image/x-icon'], // Audio. 'mid' => ['audio/midi'], 'midi' => ['audio/midi'], 'mp3' => ['audio/mpeg'], 'mpga' => ['audio/mpeg'], 'mp2' => ['audio/mpeg'], 'ogg' => ['audio/ogg'], 'wav' => ['audio/wav', 'audio/x-wav'], 'flac' => ['audio/flac'], 'aac' => ['audio/aac', 'audio/aacp', 'audio/x-hx-aac-adts'], 'aif' => ['audio/x-aiff'], 'aiff' => ['audio/x-aiff'], 'ra' => ['audio/x-realaudio'], 'm4a' => ['audio/x-m4a'], // Video. 'avi' => ['video/x-msvideo'], 'flv' => ['video/x-flv'], 'mpg' => ['video/mpeg'], 'mpeg' => ['video/mpeg'], 'mpe' => ['video/mpeg'], 'mp4' => ['video/mp4', 'audio/mp4'], 'webm' => ['video/webm', 'audio/webm'], 'ogv' => ['video/ogg'], 'mov' => ['video/quicktime'], 'moov' => ['video/quicktime'], 'qt' => ['video/quicktime'], 'movie' => ['video/x-sgi-movie'], 'rv' => ['video/vnd.rn-realvideo'], 'mkv' => ['video/x-matroska'], 'wmv' => ['video/x-ms-asf'], 'wma' => ['video/x-ms-asf'], 'asf' => ['video/x-ms-asf'], 'm4v' => ['video/x-m4v'], // Other multimedia file formats. 'psd' => ['application/x-photoshop'], 'swf' => ['application/x-shockwave-flash'], 'ai' => ['application/postscript'], 'eps' => ['application/postscript'], 'ps' => ['application/postscript'], 'mif' => ['application/vnd.mif'], 'xul' => ['application/vnd.mozilla.xul+xml'], // Source code formats. 'phps' => ['application/x-httpd-php-source'], 'js' => ['application/x-javascript'], // Archives. 'bz2' => ['application/x-bzip'], 'gz' => ['application/x-gzip'], 'tar' => ['application/x-tar'], 'tgz' => ['application/x-tar'], 'gtar' => ['application/x-gtar'], 'rar' => ['application/x-rar-compressed'], 'zip' => ['application/x-zip'], // Executables and packages. 'apk' => ['application/vnd.android.package-archive'], 'pkg' => ['application/x-newton-compatible-pkg'], 'exe' => ['application/vnd.microsoft.portable-executable'], 'msi' => ['application/x-msdownload'], // RFC822 email message. 'eml' => ['message/rfc822'], ); }