mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 08:14:38 +02:00
#12687 Fixed delete file
This commit is contained in:
parent
35713c358b
commit
15382049b8
@ -346,6 +346,8 @@ echo '</div>';
|
|||||||
"downloadDialog"
|
"downloadDialog"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const filename = '<?php echo uniqid().'.prd'; ?>';
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "GET",
|
type: "GET",
|
||||||
url: "ajax.php",
|
url: "ajax.php",
|
||||||
@ -356,6 +358,7 @@ echo '</div>';
|
|||||||
type: $("#export_type").val(),
|
type: $("#export_type").val(),
|
||||||
value: value,
|
value: value,
|
||||||
name: $("#select_value option:selected").text(),
|
name: $("#select_value option:selected").text(),
|
||||||
|
filename: filename
|
||||||
},
|
},
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
if (data.error === -1 || data.error === -2) {
|
if (data.error === -1 || data.error === -2) {
|
||||||
@ -363,7 +366,7 @@ echo '</div>';
|
|||||||
$("#confirm_downloadDialog").dialog("close");
|
$("#confirm_downloadDialog").dialog("close");
|
||||||
} else {
|
} else {
|
||||||
let a = document.createElement('a');
|
let a = document.createElement('a');
|
||||||
const url = '<?php echo $config['homeurl'].'/attachment/'; ?>' + data.name;
|
const url = '<?php echo $config['homeurl'].'/attachment/'; ?>' + filename;
|
||||||
a.href = url;
|
a.href = url;
|
||||||
a.download = data.name_download;
|
a.download = data.name_download;
|
||||||
a.click();
|
a.click();
|
||||||
@ -375,7 +378,7 @@ echo '</div>';
|
|||||||
data: {
|
data: {
|
||||||
page: 'include/ajax/resources.ajax',
|
page: 'include/ajax/resources.ajax',
|
||||||
deleteFile: 1,
|
deleteFile: 1,
|
||||||
filename: data,
|
filename: filename,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
$("#confirm_downloadDialog").dialog("close");
|
$("#confirm_downloadDialog").dialog("close");
|
||||||
@ -384,6 +387,16 @@ echo '</div>';
|
|||||||
},
|
},
|
||||||
error: function(data) {
|
error: function(data) {
|
||||||
console.error("Fatal error in AJAX call to interpreter order", data);
|
console.error("Fatal error in AJAX call to interpreter order", data);
|
||||||
|
$.ajax({
|
||||||
|
type: "DELETE",
|
||||||
|
url: "ajax.php",
|
||||||
|
data: {
|
||||||
|
page: 'include/ajax/resources.ajax',
|
||||||
|
deleteFile: 1,
|
||||||
|
filename: filename,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
$("#confirm_downloadDialog").dialog("close");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -70,13 +70,17 @@ if ((bool) is_ajax() === true) {
|
|||||||
$type = (string) get_parameter('type', '');
|
$type = (string) get_parameter('type', '');
|
||||||
$value = (int) get_parameter('value', 0);
|
$value = (int) get_parameter('value', 0);
|
||||||
$name = (string) get_parameter('name', '');
|
$name = (string) get_parameter('name', '');
|
||||||
|
$filename = (string) get_parameter('filename', '');
|
||||||
|
|
||||||
$data = $prd->exportPrd($type, $value, $name);
|
try {
|
||||||
|
$data = $prd->exportPrd($type, $value, $name);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$data = '';
|
||||||
|
}
|
||||||
|
|
||||||
$return = [];
|
$return = [];
|
||||||
|
|
||||||
if (empty($data) === false) {
|
if (empty($data) === false) {
|
||||||
$filename = uniqid().'.prd';
|
|
||||||
$filename_download = date('YmdHis').'-'.$type.'-'.$name.'.prd';
|
$filename_download = date('YmdHis').'-'.$type.'-'.$name.'.prd';
|
||||||
$file = $config['attachment_store'].'/'.$filename;
|
$file = $config['attachment_store'].'/'.$filename;
|
||||||
|
|
||||||
@ -86,6 +90,7 @@ if ((bool) is_ajax() === true) {
|
|||||||
|
|
||||||
if ($write === false) {
|
if ($write === false) {
|
||||||
$return['error'] = -2;
|
$return['error'] = -2;
|
||||||
|
unlink($config['attachment_store'].'/'.$filename);
|
||||||
} else {
|
} else {
|
||||||
$return['name'] = $filename;
|
$return['name'] = $filename;
|
||||||
$return['name_download'] = $filename_download;
|
$return['name_download'] = $filename_download;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user