diff --git a/inc/attachments.inc.php b/inc/attachments.inc.php index 0b1cc9aa..3f460d00 100644 --- a/inc/attachments.inc.php +++ b/inc/attachments.inc.php @@ -41,14 +41,16 @@ function hesk_uploadFile($i, $isTicket = true) global $hesk_settings, $hesklang, $trackingID, $hesk_error_buffer, $modsForHesk_settings; /* Return if name is empty */ - $name = $_FILES['attachment']['name'][$i]; + $name = $i == -1 + ? $_FILES['attachment']['name'] + : $_FILES['attachment']['name'][$i]; if (empty($name)) { return ''; } /* Parse the name */ - $file_realname = hesk_cleanFileName($_FILES['attachment']['name'][$i]); + $file_realname = hesk_cleanFileName($name); /* Check file extension */ $ext = strtolower(strrchr($file_realname, ".")); @@ -57,7 +59,9 @@ function hesk_uploadFile($i, $isTicket = true) } /* Check file size */ - $size = $_FILES['attachment']['size'][$i]; + $size = $i == -1 + ? $_FILES['attachment']['size'] + : $_FILES['attachment']['size'][$i]; if ($size > $hesk_settings['attachments']['max_size']) { return hesk_fileError(sprintf($hesklang['file_too_large'], $file_realname)); } else { @@ -88,7 +92,9 @@ function hesk_uploadFile($i, $isTicket = true) if (!$isTicket) { $directory = $modsForHesk_settings['kb_attach_dir']; } - $file_to_move = $_FILES['attachment']['tmp_name'][$i]; + $file_to_move = $i == -1 + ? $_FILES['attachment']['tmp_name'] + : $_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/inc/view_attachment_functions.inc.php b/inc/view_attachment_functions.inc.php index e54075b8..d238c881 100644 --- a/inc/view_attachment_functions.inc.php +++ b/inc/view_attachment_functions.inc.php @@ -298,7 +298,8 @@ function display_dropzone_field($url, $id = 'filedrop') { dictCancelUploadConfirmation: ".json_encode($hesklang['attachment_confirm_cancel']).", dictRemoveFile: ".json_encode($hesklang['attachment_remove']).", previewTemplate: $('#previews').html(), - clickable: '.filedropbutton-".$id."' + clickable: '.filedropbutton-".$id."', + uploadMultiple: false }; "; diff --git a/internal-api/admin/knowledgebase/upload-attachment.php b/internal-api/admin/knowledgebase/upload-attachment.php index c194d6df..99aeca7b 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(0, false); + $id = upload_temp_attachment(-1, 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 1a04fdbf..b98b982b 100644 --- a/internal-api/ticket/upload-attachment.php +++ b/internal-api/ticket/upload-attachment.php @@ -15,8 +15,7 @@ hesk_dbConnect(); $modsForHesk_settings = mfh_getSettings(); if (!empty($_FILES)) { - // Only 1 files is ever processed through this endpoint at a time. - $id = upload_temp_attachment(0, true); + $id = upload_temp_attachment(-1, true); print json_encode($id); return http_response_code(200); }