[opw-web] Fix error message when a too large attachment is uploaded



commit 398761c0f3f046411b2c78d117bafcd694bdd0a4
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Wed May 14 22:35:01 2014 -0400

    Fix error message when a too large attachment is uploaded
    
    If the attachment size was greater than upload_max_filesize
    specified in php.ini, a generic error message would be displayed,
    rather than a specific message telling what the maximum upload
    size is.

 modules/mod_attachment.php |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/modules/mod_attachment.php b/modules/mod_attachment.php
index 3a77b97..f7d6a4d 100644
--- a/modules/mod_attachment.php
+++ b/modules/mod_attachment.php
@@ -109,12 +109,18 @@ if ($action == 'add') {
         }
 
         if ($error_message === '') {
-            if ($_FILES['file']['error'] == 4)
+            if ($_FILES['file']['error'] == UPLOAD_ERR_NO_FILE)
                 $error_message = $lang->get('upload_no_file');
         }
 
         if ($error_message === '') {
-            if ($_FILES['file']['error'] != 0)
+            if ($_FILES['file']['error'] == UPLOAD_ERR_INI_SIZE ||
+                $_FILES['file']['error'] == UPLOAD_ERR_FORM_SIZE) {
+                $error_message = $lang->get('upload_too_large');
+        }
+
+        if ($error_message === '') {
+            if ($_FILES['file']['error'] != UPLOAD_ERR_OK)
                 $error_message = $lang->get('upload_failed');
         }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]