Correctly handle the case when MIME/Type doesn't know what file extension a mime type maps to

This commit is contained in:
Craig Andrews 2010-03-01 21:42:38 -05:00
parent d8212977ce
commit a0114f2006
1 changed files with 5 additions and 1 deletions

View File

@ -169,7 +169,11 @@ class File extends Memcached_DataObject
{
require_once 'MIME/Type/Extension.php';
$mte = new MIME_Type_Extension();
$ext = $mte->getExtension($mimetype);
try {
$ext = $mte->getExtension($mimetype);
} catch ( Exception $e) {
$ext = strtolower(preg_replace('/\W/', '', $mimetype));
}
$nickname = $profile->nickname;
$datestamp = strftime('%Y%m%dT%H%M%S', time());
$random = strtolower(common_confirmation_code(32));