diff options
-rw-r--r-- | inc/lang/en/lang.php | 1 | ||||
-rw-r--r-- | inc/media.php | 17 |
2 files changed, 15 insertions, 3 deletions
diff --git a/inc/lang/en/lang.php b/inc/lang/en/lang.php index 031ce4dab..b80668ea3 100644 --- a/inc/lang/en/lang.php +++ b/inc/lang/en/lang.php @@ -109,6 +109,7 @@ $lang['mediausage'] = 'Use the following syntax to reference this file:'; $lang['mediaview'] = 'View original file'; $lang['mediaroot'] = 'root'; $lang['mediaupload'] = 'Upload a file to the current namespace here. To create subnamespaces, prepend them to your "Upload as" filename separated by colons.'; +$lang['mediaextchange'] = 'Filextension changed from .%s to .%s!'; $lang['reference'] = 'References for'; $lang['ref_inuse'] = 'The file can\'t be deleted, because it\'s still used by the following pages:'; diff --git a/inc/media.php b/inc/media.php index 05f22719f..792064c0a 100644 --- a/inc/media.php +++ b/inc/media.php @@ -185,13 +185,24 @@ function media_upload($ns,$auth){ global $lang; global $conf; - // get file + // get file and id $id = $_POST['id']; $file = $_FILES['upload']; - // get id if(empty($id)) $id = $file['name']; - $id = cleanID($ns.':'.$id); //FIXME handle relative and absolute names here + + // check extensions + list($fext) = mimetype($file['name']); + list($iext) = mimetype($id); + if($fext && !$iext){ + // no extension specified in id - readd original one + $id .= '.'.$fext; + }elseif($fext && $fext != $iext){ + // extension was changed, print warning + msg(sprintf($lang['mediaextchange'],$fext,$iext)); + } + // get filename + $id = cleanID($ns.':'.$id); $fn = mediaFN($id); // get filetype regexp |