name = $name; $this->exts = $exts; $this->show = $show; } }; $DEFAULT_MIME_TYPE = new MimeType("application/octet-stream", array(), false); // Know mimetypes $MIME_TYPES = array(new MimeType("image/jpeg",array("jpg","jpeg","jpe"),true), new MimeType("image/gif",array("gif"),true), new MimeType("image/png",array("png"),true), new MimeType("audio/mpeg",array("mp3","mpga","mpega","mp2","m4a"),false), new MimeType("application/ogg",array("ogg"),false), new MimeType("application/pdf",array("pdf"),false), new MimeType("application/msword",array("doc"),false), new MimeType("text/plain", array("asc","txt","text","diff","pot"), true) ); // Get file extension. function extension($file) { $fileExp = explode('.', $file); // make array off the periods $filetype = $fileExp[count($fileExp) -1]; // file extension will be last index in array, -1 for 0-based indexes return strtolower($filetype); } function getMimeType($file) { global $DEFAULT_MIME_TYPE; global $MIME_TYPES; $ext = extension($file); foreach($MIME_TYPES as $m) { foreach($m->exts as $e) if($e == $ext) return $m; } return $DEFAULT_MIME_TYPE; } ?>