From 8e811cec44a1c378d193091a3d283970879bd343 Mon Sep 17 00:00:00 2001 From: Fredrick Brennan Date: Fri, 3 Nov 2017 22:12:35 +0800 Subject: [PATCH] Close #265 --- inc/config.php | 1 + post.php | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/inc/config.php b/inc/config.php index bb09b433..b1c79c63 100644 --- a/inc/config.php +++ b/inc/config.php @@ -1135,6 +1135,7 @@ $config['error']['toomanyreports'] = _('You can\'t report that many posts at once.'); $config['error']['invalidpassword'] = _('Wrong password…'); $config['error']['invalidimg'] = _('Invalid image.'); + $config['error']['phpfileserror'] = _('Upload failure (file #%index%): Error code %code%. Refer to http://php.net/manual/en/features.file-upload.errors.php; post discarded.'); $config['error']['unknownext'] = _('Unknown file extension.'); $config['error']['filesize'] = _('Maximum file size: %maxsz% bytes
Your file\'s size: %filesz% bytes'); $config['error']['maxsize'] = _('The file was too big.'); diff --git a/post.php b/post.php index c9ad915a..3f37f0f8 100644 --- a/post.php +++ b/post.php @@ -655,6 +655,13 @@ if (isset($_POST['delete'])) { if ($post['has_file']) { $i = 0; foreach ($_FILES as $key => $file) { + if ($file['error'] > 0) { + error(sprintf3($config['error']['phpfileserror'], array( + 'index' => $i+1, + 'code' => $file['error'] + ))); + } + if ($file['size'] && $file['tmp_name']) { $file['filename'] = urldecode($file['name']); $file['extension'] = strtolower(mb_substr($file['filename'], mb_strrpos($file['filename'], '.') + 1));