More work on attachments
This commit is contained in:
parent
25bb024f2c
commit
1338bb0167
@ -36,7 +36,7 @@ if (!defined('IN_SCRIPT')) {
|
|||||||
/***************************
|
/***************************
|
||||||
* Function hesk_uploadFiles()
|
* Function hesk_uploadFiles()
|
||||||
***************************/
|
***************************/
|
||||||
function hesk_uploadFile($i, $isTicket = true)
|
function hesk_uploadFile($i, $isTicket = true, $ajax = false)
|
||||||
{
|
{
|
||||||
global $hesk_settings, $hesklang, $trackingID, $hesk_error_buffer, $modsForHesk_settings;
|
global $hesk_settings, $hesklang, $trackingID, $hesk_error_buffer, $modsForHesk_settings;
|
||||||
|
|
||||||
@ -68,11 +68,16 @@ function hesk_uploadFile($i, $isTicket = true)
|
|||||||
$tmp .= $useChars{mt_rand(0, 29)};
|
$tmp .= $useChars{mt_rand(0, 29)};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($ajax) {
|
||||||
|
// Temporary attachments are, well, temporary. We can just use the real name since they'll be deleted afterwards.
|
||||||
|
$file_name = $file_realname;
|
||||||
|
} else {
|
||||||
if (defined('KB')) {
|
if (defined('KB')) {
|
||||||
$file_name = substr(md5($tmp . $file_realname), 0, 200) . $ext;
|
$file_name = substr(md5($tmp . $file_realname), 0, 200) . $ext;
|
||||||
} else {
|
} else {
|
||||||
$file_name = substr($trackingID . '_' . md5($tmp . $file_realname), 0, 200) . $ext;
|
$file_name = substr($trackingID . '_' . md5($tmp . $file_realname), 0, 200) . $ext;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Does the temporary file exist? If not, probably server-side configuration limits have been reached
|
// Does the temporary file exist? If not, probably server-side configuration limits have been reached
|
||||||
// Uncomment this for debugging purposes
|
// Uncomment this for debugging purposes
|
||||||
@ -88,6 +93,9 @@ function hesk_uploadFile($i, $isTicket = true)
|
|||||||
if (!$isTicket) {
|
if (!$isTicket) {
|
||||||
$directory = $modsForHesk_settings['kb_attach_dir'];
|
$directory = $modsForHesk_settings['kb_attach_dir'];
|
||||||
}
|
}
|
||||||
|
if ($ajax) {
|
||||||
|
$directory = $modsForHesk_settings[''];
|
||||||
|
}
|
||||||
if (!move_uploaded_file($_FILES['attachment']['tmp_name'][$i], dirname(dirname(__FILE__)) . '/' . $directory . '/' . $file_name)) {
|
if (!move_uploaded_file($_FILES['attachment']['tmp_name'][$i], dirname(dirname(__FILE__)) . '/' . $directory . '/' . $file_name)) {
|
||||||
return hesk_fileError($hesklang['cannot_move_tmp']);
|
return hesk_fileError($hesklang['cannot_move_tmp']);
|
||||||
}
|
}
|
||||||
|
@ -211,7 +211,7 @@ function display_dropzone_field($url) {
|
|||||||
<script type=\"text/javascript\">
|
<script type=\"text/javascript\">
|
||||||
Dropzone.options.filedrop = {
|
Dropzone.options.filedrop = {
|
||||||
paramName: 'file',
|
paramName: 'file',
|
||||||
url: '".$url."',
|
url: ".json_encode($url).",
|
||||||
parallelUploads: 1,
|
parallelUploads: 1,
|
||||||
uploadMultiple: false,
|
uploadMultiple: false,
|
||||||
maxFiles: 1,
|
maxFiles: 1,
|
||||||
|
16
internal-api/ticket/upload-attachment.php
Normal file
16
internal-api/ticket/upload-attachment.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
define('IN_SCRIPT', 1);
|
||||||
|
define('HESK_PATH', '../../');
|
||||||
|
define('INTERNAL_API_PATH', '../../');
|
||||||
|
require_once(HESK_PATH . 'hesk_settings.inc.php');
|
||||||
|
require_once(HESK_PATH . 'inc/common.inc.php');
|
||||||
|
require_once(INTERNAL_API_PATH . 'core/output.php');
|
||||||
|
|
||||||
|
hesk_load_internal_api_database_functions();
|
||||||
|
hesk_dbConnect();
|
||||||
|
|
||||||
|
if (!empty($_FILES)) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return http_response_code(400);
|
@ -32,7 +32,7 @@ $hesklang['warning_title_case'] = 'Warning';
|
|||||||
$hesklang['logs'] = 'Logs';
|
$hesklang['logs'] = 'Logs';
|
||||||
$hesklang['view_message_log'] = 'View Message Log';
|
$hesklang['view_message_log'] = 'View Message Log';
|
||||||
$hesklang['can_view_logs'] = 'Can view message logs';
|
$hesklang['can_view_logs'] = 'Can view message logs';
|
||||||
$hesklang['attachment_viewer_message'] = 'Drag or click here to select your file for submission.';
|
$hesklang['attachment_viewer_message'] = 'Drag or click here to select files to upload.';
|
||||||
$hesklang['attachment_invalid_type_message'] = 'Sorry, but the file type you tried to upload is not allowed.';
|
$hesklang['attachment_invalid_type_message'] = 'Sorry, but the file type you tried to upload is not allowed.';
|
||||||
$hesklang['attachment_upload_error'] = 'An error occurred when trying to upload. Please try again later.';
|
$hesklang['attachment_upload_error'] = 'An error occurred when trying to upload. Please try again later.';
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user