static public function getMimeType($contentType, $filename=null)
    {
        if ($contentType = strtolower($contentType)) {
            if (strpos($contentType, '/') !== false) {
                $mimeTypes = array_keys(self::$mime_types, $contentType);
                $ext = $filename ? pathinfo($filename, PATHINFO_EXTENSION) : null;
                
                if (count($mimeTypes) === 1) {
                    return $mimeTypes[0];
                } elseif (count($mimeTypes) > 1) {
                    return $ext && in_array($ext, $mimeTypes) ? $ext : $mimeTypes[0];
                } else {
                    return $ext ? static::getMimeType($ext) : null;
                }
            } else {
                $ext = pathinfo($contentType, PATHINFO_EXTENSION);
                if (isset(static::$mime_types[$ext])) {
                    return $ext;
                }
            }
        } elseif ($filename) {
            return static::getMimeType($filename);
        }
        
        return null;
    }
static public function getMimeType($contentType, $filename=null)
    {
        if ($contentType = strtolower($contentType)) {
            if (strpos($contentType, '/') !== false) {
                $mimeTypes = array_keys(self::$mime_types, $contentType);
                $ext = $filename ? pathinfo($filename, PATHINFO_EXTENSION) : null;
                
                if (count($mimeTypes) === 1) {
                    return $mimeTypes[0];
                } elseif (count($mimeTypes) > 1) {
                    return $ext && in_array($ext, $mimeTypes) ? $ext : $mimeTypes[0];
                } else {
                    return $ext ? static::getMimeType($ext) : null;
                }
            } else {
                $ext = pathinfo($contentType, PATHINFO_EXTENSION);
                if (isset(static::$mime_types[$ext])) {
                    return $ext;
                }
            }
        } elseif ($filename) {
            return static::getMimeType($filename);
        }
        
        return null;
    }
static public function getMimeType ( $ contentType , $ filename = null ) { if ( $ contentType = strtolower ( $ contentType ) ) { if ( strpos ( $ contentType , '/' ) !== false ) { $ mimeTypes = array_keys ( self :: $ mime_types , $ contentType ) ; $ ext = $ filename ? pathinfo ( $ filename , PATHINFO_EXTENSION ) : null ; if ( count ( $ mimeTypes ) === 1 ) { return $ mimeTypes [ 0 ] ; } elseif ( count ( $ mimeTypes ) > 1 ) { return $ ext && in_array ( $ ext , $ mimeTypes ) ? $ ext : $ mimeTypes [ 0 ] ; } else { return $ ext ? static :: getMimeType ( $ ext ) : null ; } } else { $ ext = pathinfo ( $ contentType , PATHINFO_EXTENSION ) ; if ( isset ( static :: $ mime_types [ $ ext ] ) ) { return $ ext ; } } } elseif ( $ filename ) { return static :: getMimeType ( $ filename ) ; } return null ; }
return mimetype, return mimetype like 'txt'.

@param  string $contentType contentType or filename
@param  string $filename
@return string $mimetype
return mimetype return mimetype like txt .