From db29676e1f3088dec81360698ea90790c15f3aec Mon Sep 17 00:00:00 2001 From: Janusz Dobrowolski Date: Tue, 31 Mar 2015 19:22:22 +0200 Subject: [PATCH] [0002781] Improved error diagnostic during files upload. --- admin/attachments.php | 8 +++++++- admin/company_preferences.php | 8 ++++++++ inventory/manage/items.php | 9 +++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/admin/attachments.php b/admin/attachments.php index 4803ca77..bd567bf2 100644 --- a/admin/attachments.php +++ b/admin/attachments.php @@ -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']; diff --git a/admin/company_preferences.php b/admin/company_preferences.php index 186d06bf..74b7071b 100644 --- a/admin/company_preferences.php +++ b/admin/company_preferences.php @@ -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)) diff --git a/inventory/manage/items.php b/inventory/manage/items.php index 54df94bf..e3d710ee 100644 --- a/inventory/manage/items.php +++ b/inventory/manage/items.php @@ -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) -- 2.30.2