4 function z_mime_content_type($filename) {
10 'html' => 'text/html',
13 'js' => 'application/javascript',
14 'json' => 'application/json',
15 'xml' => 'application/xml',
16 'swf' => 'application/x-shockwave-flash',
17 'flv' => 'video/x-flv',
21 'jpe' => 'image/jpeg',
22 'jpeg' => 'image/jpeg',
23 'jpg' => 'image/jpeg',
26 'ico' => 'image/vnd.microsoft.icon',
27 'tiff' => 'image/tiff',
28 'tif' => 'image/tiff',
29 'svg' => 'image/svg+xml',
30 'svgz' => 'image/svg+xml',
33 'zip' => 'application/zip',
34 'rar' => 'application/x-rar-compressed',
35 'exe' => 'application/x-msdownload',
36 'msi' => 'application/x-msdownload',
37 'cab' => 'application/vnd.ms-cab-compressed',
40 'mp3' => 'audio/mpeg',
42 'qt' => 'video/quicktime',
43 'mov' => 'video/quicktime',
44 'ogg' => 'application/ogg',
47 'pdf' => 'application/pdf',
48 'psd' => 'image/vnd.adobe.photoshop',
49 'ai' => 'application/postscript',
50 'eps' => 'application/postscript',
51 'ps' => 'application/postscript',
54 'doc' => 'application/msword',
55 'rtf' => 'application/rtf',
56 'xls' => 'application/vnd.ms-excel',
57 'ppt' => 'application/vnd.ms-powerpoint',
61 'odt' => 'application/vnd.oasis.opendocument.text',
62 'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
65 $dot = strpos($filename,'.');
67 $ext = strtolower(substr($filename,$dot+1));
68 if (array_key_exists($ext, $mime_types)) {
69 return $mime_types[$ext];
72 // can't use this because we're just passing a name, e.g. not a file that can be opened
73 // elseif (function_exists('finfo_open')) {
74 // $finfo = @finfo_open(FILEINFO_MIME);
75 // $mimetype = @finfo_file($finfo, $filename);
76 // @finfo_close($finfo);
80 return 'application/octet-stream';