Ejemplo n.º 1
0
 /**
  * Return the MIME type for the extension provided.
  *
  * Takes a full file name, or a file extension with or without
  * the dot as an argument, i.e. 'contrexx.zip', '.gif, or 'txt'.
  * Returns the string 'application/octet-stream' for any unknown ending.
  * Use {@link isKnownExtension()} to test exactly that.
  * @static
  * @param   string     $strExtension    The file extension
  * @return  string                      The corresponding MIME type
  * @author  Reto Kohli <*****@*****.**>
  */
 static function getMimeTypeForExtension($strExtension)
 {
     // Make sure only the extension is present.
     // Chop the file name up to and including  the last dot
     $strChoppedExtension = preg_replace('/^.*\\./', '', $strExtension);
     if (Mime::isKnownExtension($strChoppedExtension)) {
         return self::$arrExtensions2MimeTypes[$strChoppedExtension];
     }
     return self::$strDefaultType;
 }