Correction envoie de fichier

This commit is contained in:
Nicolas H 2022-05-25 18:37:57 +02:00
parent b0d16ccfe7
commit bfb7fd51e8
2 changed files with 9 additions and 13 deletions

View File

@ -136,7 +136,6 @@ else if (isset($_POST['action']))
exit;
case 'sendfile':
$file=urldecode($_POST['name']);
$filedetail = pathinfo($file);
$data=file_get_contents($_FILES["file"]["tmp_name"]);
unlink($_FILES["file"]["tmp_name"]);
if (!isset($_SESSION['md_admin']))
@ -145,11 +144,7 @@ else if (isset($_POST['action']))
}
else
{
if (in_array($filedetail['extension'], $supported_image))
$path="/images";
else
$path="/documents";
print(setcontent($path."/".$file,$data));
print(setcontent($file,$data));
}
exit;
case 'allchildren':

View File

@ -252,11 +252,13 @@ $(function(){
$("#files").on("select_node.jstree", function (e, nodes) {
file="/"+$("#files").jstree("get_path",nodes.node,"/").replace(/^.+?[/]/, '');
if ($("#files").jstree("is_leaf",nodes.node))
if ($("#files").jstree("get_icon",nodes.node)!="far fa-folder")
{
openlink(file,false);
}
else
{
sendmode();
sendmode(file);
}
});
@ -512,6 +514,7 @@ function handleDrop(e) {
var dt = e.dataTransfer
var files = dt.files
handleFiles(files)
$("#files").jstree("refresh");
}
let uploadProgress = []
@ -519,7 +522,6 @@ let uploadProgress = []
function initializeProgress(numFiles) {
document.getElementById("progress-bar").value = 0
uploadProgress = []
for(let i = numFiles; i > 0; i--) {
uploadProgress.push(0)
}
@ -555,11 +557,9 @@ function uploadFile(file, i) {
var formData = new FormData()
xhr.open('POST', url, true)
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest')
xhr.upload.addEventListener("progress", function(e) {
updateProgress(i, (e.loaded * 100.0 / e.total) || 100)
})
xhr.addEventListener('readystatechange', function(e) {
if (xhr.readyState == 4 && xhr.status == 200) {
updateProgress(i, 100)
@ -567,9 +567,10 @@ function uploadFile(file, i) {
else if (xhr.readyState == 4 && xhr.status != 200) {
}
})
formData.append('file', file)
formData.append('name', file.name);
node=$("#files").jstree("get_selected");
path="/"+$("#files").jstree("get_path",node,"/").replace(/^.+?[/]/, '');
formData.append('name', path+"/"+file.name);
formData.append('action','sendfile');
xhr.send(formData)
}