[0002781] Improved error diagnostic during files upload.
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Tue, 31 Mar 2015 17:22:22 +0000 (19:22 +0200)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Tue, 31 Mar 2015 17:22:22 +0000 (19:22 +0200)
admin/attachments.php
admin/company_preferences.php
inventory/manage/items.php

index 4803ca771e00744abfeab67b1999db85882a1def..bd567bf23684dfee55970b98789a274138135d92 100644 (file)
@@ -84,8 +84,14 @@ if ($Mode == 'ADD_ITEM' || $Mode == 'UPDATE_ITEM')
 {
        if (!transaction_exists($_POST['filterType'], $_POST['trans_no']))
                display_error(_("Selected transaction does not exists."));
-       elseif ($Mode == 'ADD_ITEM' && (!isset($_FILES['filename']) || $_FILES['filename']['size'] == 0))
+       elseif ($Mode == 'ADD_ITEM' && !isset($_FILES['filename']))
                display_error(_("Select attachment file."));
+       elseif ($Mode == 'ADD_ITEM' && ($_FILES['filename']['error'] > 0)) {
+    if ($_FILES['filename']['error'] == UPLOAD_ERR_INI_SIZE) 
+                 display_error(_("The file size is over the maximum allowed."));
+    else
+                 display_error(_("Select attachment file."));
+  }
        else {
                //$content = base64_encode(file_get_contents($_FILES['filename']['tmp_name']));
                $tmpname = $_FILES['filename']['tmp_name'];
index 186d06bf848f45e0d419a7595e61c383597a3f6c..74b7071bbe76a9b4e926bd1f045fa9809d6c1946 100644 (file)
@@ -38,6 +38,14 @@ if (isset($_POST['update']) && $_POST['update'] != "")
        }
        if (isset($_FILES['pic']) && $_FILES['pic']['name'] != '')
        {
+    if ($_FILES['pic']['error'] == UPLOAD_ERR_INI_SIZE) {
+                       display_error(_('The file size is over the maximum allowed.'));
+                       $input_error = 1;
+    }
+    elseif ($_FILES['pic']['error'] > 0) {
+                       display_error(_('Error uploading logo file.'));
+                       $input_error = 1;
+    }
                $result = $_FILES['pic']['error'];
                $filename = company_path()."/images";
                if (!file_exists($filename))
index 54df94bf68969db2202871c05bdb4734385f68a9..e3d710ee054db4c40dae837b02b5082556f2cc9f 100644 (file)
@@ -64,6 +64,15 @@ if (isset($_FILES['pic']) && $_FILES['pic']['name'] != '')
                mkdir($filename);
        }       
        $filename .= "/".item_img_name($stock_id).".jpg";
+
+  if ($_FILES['pic']['error'] == UPLOAD_ERR_INI_SIZE) {
+    display_error(_('The file size is over the maximum allowed.'));
+               $upload_file ='No';
+  }
+  elseif ($_FILES['pic']['error'] > 0) {
+               display_error(_('Error uploading file.'));
+               $upload_file ='No';
+  }
        
        //But check for the worst 
        if ((list($width, $height, $type, $attr) = getimagesize($_FILES['pic']['tmp_name'])) !== false)