From a93e6f851f16103e0293124cf566c99a5493b2e7 Mon Sep 17 00:00:00 2001 From: Andreas Gohr <andi@splitbrain.org> Date: Fri, 16 Jan 2009 14:50:17 +0100 Subject: [PATCH] catch too big uploads FS#1552 darcs-hash:20090116135017-7ad00-5815811717b4b5eb86698e57277e9ae74c660883.gz --- inc/lang/en/lang.php | 1 + lib/exe/mediamanager.php | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/inc/lang/en/lang.php b/inc/lang/en/lang.php index 26f6bcd45..e206f2fc9 100644 --- a/inc/lang/en/lang.php +++ b/inc/lang/en/lang.php @@ -113,6 +113,7 @@ $lang['uploadexist'] = 'File already exists. Nothing done.'; $lang['uploadbadcontent'] = 'The uploaded content did not match the %s file extension.'; $lang['uploadspam'] = 'The upload was blocked by the spam blacklist.'; $lang['uploadxss'] = 'The upload was blocked for possibly malicious content.'; +$lang['uploadsize'] = 'The uploaded file was too big. (max. %s)'; $lang['deletesucc'] = 'The file "%s" has been deleted.'; $lang['deletefail'] = '"%s" couldn\'t be deleted - check permissions.'; $lang['mediainuse'] = 'The file "%s" hasn\'t been deleted - it is still in use.'; diff --git a/lib/exe/mediamanager.php b/lib/exe/mediamanager.php index a83d5d772..97afae9b7 100644 --- a/lib/exe/mediamanager.php +++ b/lib/exe/mediamanager.php @@ -53,6 +53,16 @@ exit; } + // give info on PHP catched upload errors + if($_FILES['upload']['error']) switch($_FILES['upload']['error']){ + case 1: + case 2: + msg(sprintf($lang['uploadsize'], + filesize_h(php_to_byte(ini_get('upload_max_filesize')))),-1); + break; + default: + msg($lang['uploadfail'],-1); + } // handle upload if($_FILES['upload']['tmp_name']){ -- GitLab