From bfb7fd51e801f48bc013380c1e401a021b5ff11a Mon Sep 17 00:00:00 2001 From: Nicolas H Date: Wed, 25 May 2022 18:37:57 +0200 Subject: [PATCH] Correction envoie de fichier --- index.php | 7 +------ js/functionsadmin.js | 15 ++++++++------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/index.php b/index.php index 9c2ebf9..de19c68 100644 --- a/index.php +++ b/index.php @@ -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': diff --git a/js/functionsadmin.js b/js/functionsadmin.js index ae42db5..a2fe3ce 100644 --- a/js/functionsadmin.js +++ b/js/functionsadmin.js @@ -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) }