X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=admin%2Fattachments.php;h=e92276ed87fd2934596504ff9147e178394a4542;hb=2aea99756a8c19766f0f9dfee56b27f7c1994f37;hp=4803ca771e00744abfeab67b1999db85882a1def;hpb=5e63c6ace55729bbb5ee3b060035a25a4426eb0a;p=fa-stable.git diff --git a/admin/attachments.php b/admin/attachments.php index 4803ca77..e92276ed 100644 --- a/admin/attachments.php +++ b/admin/attachments.php @@ -36,10 +36,7 @@ if ($view_id != -1) $type = ($row['filetype']) ? $row['filetype'] : 'application/octet-stream'; header("Content-type: ".$type); header('Content-Length: '.$row['filesize']); - //if ($type == 'application/octet-stream') - // header('Content-Disposition: attachment; filename='.$row['filename']); - //else - header("Content-Disposition: inline"); + header("Content-Disposition: inline"); echo file_get_contents(company_path(). "/attachments/".$row['unique_name']); exit(); } @@ -84,8 +81,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']; @@ -116,7 +119,7 @@ if ($Mode == 'ADD_ITEM' || $Mode == 'UPDATE_ITEM') unlink($dir."/".$unique_name); } else - $unique_name = uniqid(''); + $unique_name = random_id(); //save the file move_uploaded_file($tmpname, $dir."/".$unique_name); @@ -166,7 +169,7 @@ function viewing_controls() start_row(); systypes_list_cells(_("Type:"), 'filterType', null, true); if (list_updated('filterType')) - $selected_id = -1;; + $selected_id = -1; end_row(); end_table(1);