From f9ec18ce5fa852479e3b5919e37753ba07fbc460 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Fri, 6 May 2016 12:27:17 -0400 Subject: [PATCH] Fix drag-and-drop for attachments --- inc/attachments.inc.php | 20 ++++--------------- .../admin/knowledgebase/upload-attachment.php | 2 +- internal-api/ticket/upload-attachment.php | 2 +- 3 files changed, 6 insertions(+), 18 deletions(-) diff --git a/inc/attachments.inc.php b/inc/attachments.inc.php index 3b8edcdd..0b1cc9aa 100644 --- a/inc/attachments.inc.php +++ b/inc/attachments.inc.php @@ -40,23 +40,15 @@ function hesk_uploadFile($i, $isTicket = true) { global $hesk_settings, $hesklang, $trackingID, $hesk_error_buffer, $modsForHesk_settings; - $single_file = $i == -1; /* Return if name is empty */ - $name = $single_file - ? $_FILES['attachment']['name'] - : $_FILES['attachment']['name'][$i]; - + $name = $_FILES['attachment']['name'][$i]; if (empty($name)) { return ''; } /* Parse the name */ - if ($single_file) { - $file_realname = hesk_cleanFileName($_FILES['attachment']['name']); - } else { - $file_realname = hesk_cleanFileName($_FILES['attachment']['name'][$i]); - } + $file_realname = hesk_cleanFileName($_FILES['attachment']['name'][$i]); /* Check file extension */ $ext = strtolower(strrchr($file_realname, ".")); @@ -65,9 +57,7 @@ function hesk_uploadFile($i, $isTicket = true) } /* Check file size */ - $size = $single_file - ? $_FILES['attachment']['size'] - : $_FILES['attachment']['size'][$i]; + $size = $_FILES['attachment']['size'][$i]; if ($size > $hesk_settings['attachments']['max_size']) { return hesk_fileError(sprintf($hesklang['file_too_large'], $file_realname)); } else { @@ -98,9 +88,7 @@ function hesk_uploadFile($i, $isTicket = true) if (!$isTicket) { $directory = $modsForHesk_settings['kb_attach_dir']; } - $file_to_move = $single_file - ? $_FILES['attachment']['tmp_name'] - : $_FILES['attachment']['tmp_name'][$i]; + $file_to_move = $_FILES['attachment']['tmp_name'][$i]; if (!move_uploaded_file($file_to_move, dirname(dirname(__FILE__)) . '/' . $directory . '/' . $file_name)) { return hesk_fileError($hesklang['cannot_move_tmp']); } diff --git a/internal-api/admin/knowledgebase/upload-attachment.php b/internal-api/admin/knowledgebase/upload-attachment.php index 99aeca7b..c194d6df 100644 --- a/internal-api/admin/knowledgebase/upload-attachment.php +++ b/internal-api/admin/knowledgebase/upload-attachment.php @@ -16,7 +16,7 @@ $modsForHesk_settings = mfh_getSettings(); if (!empty($_FILES)) { // Only 1 files is ever processed through this endpoint at a time. - $id = upload_temp_attachment(-1, false); + $id = upload_temp_attachment(0, false); print json_encode($id); return http_response_code(200); } diff --git a/internal-api/ticket/upload-attachment.php b/internal-api/ticket/upload-attachment.php index e66d4c2d..1a04fdbf 100644 --- a/internal-api/ticket/upload-attachment.php +++ b/internal-api/ticket/upload-attachment.php @@ -16,7 +16,7 @@ $modsForHesk_settings = mfh_getSettings(); if (!empty($_FILES)) { // Only 1 files is ever processed through this endpoint at a time. - $id = upload_temp_attachment(-1, true); + $id = upload_temp_attachment(0, true); print json_encode($id); return http_response_code(200); }