Correction envoie de fichier
This commit is contained in:
parent
b0d16ccfe7
commit
bfb7fd51e8
|
@ -136,7 +136,6 @@ else if (isset($_POST['action']))
|
||||||
exit;
|
exit;
|
||||||
case 'sendfile':
|
case 'sendfile':
|
||||||
$file=urldecode($_POST['name']);
|
$file=urldecode($_POST['name']);
|
||||||
$filedetail = pathinfo($file);
|
|
||||||
$data=file_get_contents($_FILES["file"]["tmp_name"]);
|
$data=file_get_contents($_FILES["file"]["tmp_name"]);
|
||||||
unlink($_FILES["file"]["tmp_name"]);
|
unlink($_FILES["file"]["tmp_name"]);
|
||||||
if (!isset($_SESSION['md_admin']))
|
if (!isset($_SESSION['md_admin']))
|
||||||
|
@ -145,11 +144,7 @@ else if (isset($_POST['action']))
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (in_array($filedetail['extension'], $supported_image))
|
print(setcontent($file,$data));
|
||||||
$path="/images";
|
|
||||||
else
|
|
||||||
$path="/documents";
|
|
||||||
print(setcontent($path."/".$file,$data));
|
|
||||||
}
|
}
|
||||||
exit;
|
exit;
|
||||||
case 'allchildren':
|
case 'allchildren':
|
||||||
|
|
|
@ -252,11 +252,13 @@ $(function(){
|
||||||
|
|
||||||
$("#files").on("select_node.jstree", function (e, nodes) {
|
$("#files").on("select_node.jstree", function (e, nodes) {
|
||||||
file="/"+$("#files").jstree("get_path",nodes.node,"/").replace(/^.+?[/]/, '');
|
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);
|
openlink(file,false);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sendmode();
|
sendmode(file);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -512,6 +514,7 @@ function handleDrop(e) {
|
||||||
var dt = e.dataTransfer
|
var dt = e.dataTransfer
|
||||||
var files = dt.files
|
var files = dt.files
|
||||||
handleFiles(files)
|
handleFiles(files)
|
||||||
|
$("#files").jstree("refresh");
|
||||||
}
|
}
|
||||||
|
|
||||||
let uploadProgress = []
|
let uploadProgress = []
|
||||||
|
@ -519,7 +522,6 @@ let uploadProgress = []
|
||||||
function initializeProgress(numFiles) {
|
function initializeProgress(numFiles) {
|
||||||
document.getElementById("progress-bar").value = 0
|
document.getElementById("progress-bar").value = 0
|
||||||
uploadProgress = []
|
uploadProgress = []
|
||||||
|
|
||||||
for(let i = numFiles; i > 0; i--) {
|
for(let i = numFiles; i > 0; i--) {
|
||||||
uploadProgress.push(0)
|
uploadProgress.push(0)
|
||||||
}
|
}
|
||||||
|
@ -555,11 +557,9 @@ function uploadFile(file, i) {
|
||||||
var formData = new FormData()
|
var formData = new FormData()
|
||||||
xhr.open('POST', url, true)
|
xhr.open('POST', url, true)
|
||||||
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest')
|
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest')
|
||||||
|
|
||||||
xhr.upload.addEventListener("progress", function(e) {
|
xhr.upload.addEventListener("progress", function(e) {
|
||||||
updateProgress(i, (e.loaded * 100.0 / e.total) || 100)
|
updateProgress(i, (e.loaded * 100.0 / e.total) || 100)
|
||||||
})
|
})
|
||||||
|
|
||||||
xhr.addEventListener('readystatechange', function(e) {
|
xhr.addEventListener('readystatechange', function(e) {
|
||||||
if (xhr.readyState == 4 && xhr.status == 200) {
|
if (xhr.readyState == 4 && xhr.status == 200) {
|
||||||
updateProgress(i, 100)
|
updateProgress(i, 100)
|
||||||
|
@ -567,9 +567,10 @@ function uploadFile(file, i) {
|
||||||
else if (xhr.readyState == 4 && xhr.status != 200) {
|
else if (xhr.readyState == 4 && xhr.status != 200) {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
formData.append('file', file)
|
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');
|
formData.append('action','sendfile');
|
||||||
xhr.send(formData)
|
xhr.send(formData)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue