static function guessMimeType($file, $def = 'application/octet-stream')
	{
		// extract file extension (after . symbol)
		$ext = substr(strrchr(strtolower($file), '.'), 1);
	
		switch ( $ext )
		{
			case 'gif':
			case 'jpeg':
			case 'png':
				return "image/$ext";
			case 'jpg':
				return 'image/jpeg';
			case 'mp4':
			case 'mpeg':
			case 'avi':
				return "video/$ext";
			case 'mp3':
				return 'audio/mpeg3';
			case 'wav':
				return 'audio/wav';
			case 'pdf':
				return 'application/pdf';
			case 'htm':
			case 'html':
				return 'text/html';
			case 'txt':
				return 'text/plain';
			case 'eml':
				return 'message/rfc822';
			case 'doc':
				return 'application/msword';
			case 'docx':
				return 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
			case 'xls':
				return 'application/vnd.ms-excel';
			case 'xlsx':
				return 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
			case 'ppt':
			case 'pps':
				return 'application/vnd.ms-powerpoint';
			case 'pptx':
			case 'ppsx':
				return 'application/vnd.openxmlformats-officedocument.presentationml.presentation';
			case 'odt':
				return 'application/vnd.oasis.opendocument.text';
			case 'ods':
				return 'application/vnd.oasis.opendocument.spreadsheet';
			case 'odp':
				return 'application/vnd.oasis.opendocument.presentation';
			case 'zip':
				return 'application/zip';
			default :
				return $def;
		}
	}
static function guessMimeType($file, $def = 'application/octet-stream')
	{
		// extract file extension (after . symbol)
		$ext = substr(strrchr(strtolower($file), '.'), 1);
	
		switch ( $ext )
		{
			case 'gif':
			case 'jpeg':
			case 'png':
				return "image/$ext";
			case 'jpg':
				return 'image/jpeg';
			case 'mp4':
			case 'mpeg':
			case 'avi':
				return "video/$ext";
			case 'mp3':
				return 'audio/mpeg3';
			case 'wav':
				return 'audio/wav';
			case 'pdf':
				return 'application/pdf';
			case 'htm':
			case 'html':
				return 'text/html';
			case 'txt':
				return 'text/plain';
			case 'eml':
				return 'message/rfc822';
			case 'doc':
				return 'application/msword';
			case 'docx':
				return 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
			case 'xls':
				return 'application/vnd.ms-excel';
			case 'xlsx':
				return 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
			case 'ppt':
			case 'pps':
				return 'application/vnd.ms-powerpoint';
			case 'pptx':
			case 'ppsx':
				return 'application/vnd.openxmlformats-officedocument.presentationml.presentation';
			case 'odt':
				return 'application/vnd.oasis.opendocument.text';
			case 'ods':
				return 'application/vnd.oasis.opendocument.spreadsheet';
			case 'odp':
				return 'application/vnd.oasis.opendocument.presentation';
			case 'zip':
				return 'application/zip';
			default :
				return $def;
		}
	}
static function guessMimeType ( $ file , $ def = 'application/octet-stream' ) { // extract file extension (after . symbol) $ ext = substr ( strrchr ( strtolower ( $ file ) , '.' ) , 1 ) ; switch ( $ ext ) { case 'gif' : case 'jpeg' : case 'png' : return "image/$ext" ; case 'jpg' : return 'image/jpeg' ; case 'mp4' : case 'mpeg' : case 'avi' : return "video/$ext" ; case 'mp3' : return 'audio/mpeg3' ; case 'wav' : return 'audio/wav' ; case 'pdf' : return 'application/pdf' ; case 'htm' : case 'html' : return 'text/html' ; case 'txt' : return 'text/plain' ; case 'eml' : return 'message/rfc822' ; case 'doc' : return 'application/msword' ; case 'docx' : return 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' ; case 'xls' : return 'application/vnd.ms-excel' ; case 'xlsx' : return 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' ; case 'ppt' : case 'pps' : return 'application/vnd.ms-powerpoint' ; case 'pptx' : case 'ppsx' : return 'application/vnd.openxmlformats-officedocument.presentationml.presentation' ; case 'odt' : return 'application/vnd.oasis.opendocument.text' ; case 'ods' : return 'application/vnd.oasis.opendocument.spreadsheet' ; case 'odp' : return 'application/vnd.oasis.opendocument.presentation' ; case 'zip' : return 'application/zip' ; default : return $ def ; } }
Guess Mime type from file name

@param string $file Filename to process
@param string $def Default value for Mime type
@return string The Mime type guessed from the filename
Guess Mime type from file name