equal
deleted
inserted
replaced
|
1 <?php |
|
2 |
|
3 namespace CorpusParole\Libraries; |
|
4 |
|
5 /** |
|
6 * Utilities functions |
|
7 */ |
|
8 class Utils { |
|
9 |
|
10 /* |
|
11 * From http://www.thecave.info/php-get-mime-type-from-file-extension/ |
|
12 */ |
|
13 public static function get_mimetype($file) { |
|
14 |
|
15 // our list of mime types |
|
16 $mime_types = array( |
|
17 "pdf"=>"application/pdf", |
|
18 "exe"=>"application/octet-stream", |
|
19 "zip"=>"application/zip", |
|
20 "docx"=>"application/msword", |
|
21 "doc"=>"application/msword", |
|
22 "xls"=>"application/vnd.ms-excel", |
|
23 "ppt"=>"application/vnd.ms-powerpoint", |
|
24 "gif"=>"image/gif", |
|
25 "png"=>"image/png", |
|
26 "jpeg"=>"image/jpg", |
|
27 "jpg"=>"image/jpg", |
|
28 "mp3"=>"audio/mpeg", |
|
29 "wav"=>"audio/x-wav", |
|
30 "mpeg"=>"video/mpeg", |
|
31 "mpg"=>"video/mpeg", |
|
32 "mpe"=>"video/mpeg", |
|
33 "mov"=>"video/quicktime", |
|
34 "avi"=>"video/x-msvideo", |
|
35 "3gp"=>"video/3gpp", |
|
36 "css"=>"text/css", |
|
37 "jsc"=>"application/javascript", |
|
38 "js"=>"application/javascript", |
|
39 "php"=>"text/html", |
|
40 "htm"=>"text/html", |
|
41 "html"=>"text/html" |
|
42 ); |
|
43 |
|
44 $split_ext = explode('.',$file); |
|
45 $extension = strtolower(end($split_ext)); |
|
46 |
|
47 return $mime_types[$extension]; |
|
48 } |
|
49 } |