mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-04-08 18:55:09 +02:00
#12687 Fixed delete file
This commit is contained in:
parent
35713c358b
commit
15382049b8
@ -346,6 +346,8 @@ echo '</div>';
|
||||
"downloadDialog"
|
||||
);
|
||||
|
||||
const filename = '<?php echo uniqid().'.prd'; ?>';
|
||||
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "ajax.php",
|
||||
@ -356,6 +358,7 @@ echo '</div>';
|
||||
type: $("#export_type").val(),
|
||||
value: value,
|
||||
name: $("#select_value option:selected").text(),
|
||||
filename: filename
|
||||
},
|
||||
success: function(data) {
|
||||
if (data.error === -1 || data.error === -2) {
|
||||
@ -363,7 +366,7 @@ echo '</div>';
|
||||
$("#confirm_downloadDialog").dialog("close");
|
||||
} else {
|
||||
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.download = data.name_download;
|
||||
a.click();
|
||||
@ -375,7 +378,7 @@ echo '</div>';
|
||||
data: {
|
||||
page: 'include/ajax/resources.ajax',
|
||||
deleteFile: 1,
|
||||
filename: data,
|
||||
filename: filename,
|
||||
},
|
||||
});
|
||||
$("#confirm_downloadDialog").dialog("close");
|
||||
@ -384,6 +387,16 @@ echo '</div>';
|
||||
},
|
||||
error: function(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', '');
|
||||
$value = (int) get_parameter('value', 0);
|
||||
$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 = [];
|
||||
|
||||
if (empty($data) === false) {
|
||||
$filename = uniqid().'.prd';
|
||||
$filename_download = date('YmdHis').'-'.$type.'-'.$name.'.prd';
|
||||
$file = $config['attachment_store'].'/'.$filename;
|
||||
|
||||
@ -86,6 +90,7 @@ if ((bool) is_ajax() === true) {
|
||||
|
||||
if ($write === false) {
|
||||
$return['error'] = -2;
|
||||
unlink($config['attachment_store'].'/'.$filename);
|
||||
} else {
|
||||
$return['name'] = $filename;
|
||||
$return['name_download'] = $filename_download;
|
||||
|
Loading…
x
Reference in New Issue
Block a user