Fix file upload when multiple files are selected at once
This commit is contained in:
parent
4a86d9ddbb
commit
dd5c5a90d3
@ -41,14 +41,16 @@ function hesk_uploadFile($i, $isTicket = true)
|
|||||||
global $hesk_settings, $hesklang, $trackingID, $hesk_error_buffer, $modsForHesk_settings;
|
global $hesk_settings, $hesklang, $trackingID, $hesk_error_buffer, $modsForHesk_settings;
|
||||||
|
|
||||||
/* Return if name is empty */
|
/* Return if name is empty */
|
||||||
$name = $_FILES['attachment']['name'][$i];
|
$name = $i == -1
|
||||||
|
? $_FILES['attachment']['name']
|
||||||
|
: $_FILES['attachment']['name'][$i];
|
||||||
if (empty($name)) {
|
if (empty($name)) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Parse the name */
|
/* Parse the name */
|
||||||
$file_realname = hesk_cleanFileName($_FILES['attachment']['name'][$i]);
|
$file_realname = hesk_cleanFileName($name);
|
||||||
|
|
||||||
/* Check file extension */
|
/* Check file extension */
|
||||||
$ext = strtolower(strrchr($file_realname, "."));
|
$ext = strtolower(strrchr($file_realname, "."));
|
||||||
@ -57,7 +59,9 @@ function hesk_uploadFile($i, $isTicket = true)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Check file size */
|
/* 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']) {
|
if ($size > $hesk_settings['attachments']['max_size']) {
|
||||||
return hesk_fileError(sprintf($hesklang['file_too_large'], $file_realname));
|
return hesk_fileError(sprintf($hesklang['file_too_large'], $file_realname));
|
||||||
} else {
|
} else {
|
||||||
@ -88,7 +92,9 @@ function hesk_uploadFile($i, $isTicket = true)
|
|||||||
if (!$isTicket) {
|
if (!$isTicket) {
|
||||||
$directory = $modsForHesk_settings['kb_attach_dir'];
|
$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)) {
|
if (!move_uploaded_file($file_to_move, dirname(dirname(__FILE__)) . '/' . $directory . '/' . $file_name)) {
|
||||||
return hesk_fileError($hesklang['cannot_move_tmp']);
|
return hesk_fileError($hesklang['cannot_move_tmp']);
|
||||||
}
|
}
|
||||||
|
@ -298,7 +298,8 @@ function display_dropzone_field($url, $id = 'filedrop') {
|
|||||||
dictCancelUploadConfirmation: ".json_encode($hesklang['attachment_confirm_cancel']).",
|
dictCancelUploadConfirmation: ".json_encode($hesklang['attachment_confirm_cancel']).",
|
||||||
dictRemoveFile: ".json_encode($hesklang['attachment_remove']).",
|
dictRemoveFile: ".json_encode($hesklang['attachment_remove']).",
|
||||||
previewTemplate: $('#previews').html(),
|
previewTemplate: $('#previews').html(),
|
||||||
clickable: '.filedropbutton-".$id."'
|
clickable: '.filedropbutton-".$id."',
|
||||||
|
uploadMultiple: false
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
";
|
";
|
||||||
|
@ -16,7 +16,7 @@ $modsForHesk_settings = mfh_getSettings();
|
|||||||
|
|
||||||
if (!empty($_FILES)) {
|
if (!empty($_FILES)) {
|
||||||
// Only 1 files is ever processed through this endpoint at a time.
|
// 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);
|
print json_encode($id);
|
||||||
return http_response_code(200);
|
return http_response_code(200);
|
||||||
}
|
}
|
||||||
|
@ -15,8 +15,7 @@ hesk_dbConnect();
|
|||||||
$modsForHesk_settings = mfh_getSettings();
|
$modsForHesk_settings = mfh_getSettings();
|
||||||
|
|
||||||
if (!empty($_FILES)) {
|
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);
|
print json_encode($id);
|
||||||
return http_response_code(200);
|
return http_response_code(200);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user