Fix drag-and-drop for attachments
This commit is contained in:
parent
580a662ce0
commit
f9ec18ce5f
@ -40,23 +40,15 @@ 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;
|
||||||
|
|
||||||
$single_file = $i == -1;
|
|
||||||
/* Return if name is empty */
|
/* Return if name is empty */
|
||||||
$name = $single_file
|
$name = $_FILES['attachment']['name'][$i];
|
||||||
? $_FILES['attachment']['name']
|
|
||||||
: $_FILES['attachment']['name'][$i];
|
|
||||||
|
|
||||||
if (empty($name)) {
|
if (empty($name)) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Parse the name */
|
/* 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 */
|
/* Check file extension */
|
||||||
$ext = strtolower(strrchr($file_realname, "."));
|
$ext = strtolower(strrchr($file_realname, "."));
|
||||||
@ -65,9 +57,7 @@ function hesk_uploadFile($i, $isTicket = true)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Check file size */
|
/* Check file size */
|
||||||
$size = $single_file
|
$size = $_FILES['attachment']['size'][$i];
|
||||||
? $_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 {
|
||||||
@ -98,9 +88,7 @@ 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 = $single_file
|
$file_to_move = $_FILES['attachment']['tmp_name'][$i];
|
||||||
? $_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']);
|
||||||
}
|
}
|
||||||
|
@ -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(-1, false);
|
$id = upload_temp_attachment(0, false);
|
||||||
print json_encode($id);
|
print json_encode($id);
|
||||||
return http_response_code(200);
|
return http_response_code(200);
|
||||||
}
|
}
|
||||||
|
@ -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(-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