Add Upload Component for Files Component
All checks were successful
Neutral/pipeline/head This commit looks good
All checks were successful
Neutral/pipeline/head This commit looks good
This commit is contained in:
parent
3bee5b2aed
commit
c9f45ef82f
@ -298,7 +298,6 @@ body {
|
||||
|
||||
display: flex;
|
||||
justify-content: start;
|
||||
gap: 1vw;
|
||||
flex-direction: column;
|
||||
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
<h1><i class="fa fa-folder"></i> Fichiers</h1>
|
||||
<div>
|
||||
<button id="fi_new_folder" class="fi_act_btn"><i class="fa fa-folder"></i> Nouveau dossier</button>
|
||||
<input id='fi_upload_file' type='file' hidden multiple />
|
||||
<button id="fi_upload" class="fi_act_btn"><i class="fa fa-upload"></i> Upload</button>
|
||||
</div>
|
||||
</div>
|
||||
@ -154,10 +155,72 @@
|
||||
})
|
||||
|
||||
const uploadBtn = document.getElementById("fi_upload")
|
||||
const uploadFiles = document.getElementById("fi_upload_file")
|
||||
|
||||
|
||||
uploadBtn.addEventListener("click", () => {
|
||||
|
||||
document.getElementById("_rename").showModal()
|
||||
uploadFiles.click()
|
||||
|
||||
})
|
||||
|
||||
uploadFiles.addEventListener("change", () => {
|
||||
|
||||
var stopSend = false
|
||||
fiInfo.innerHTML = ""
|
||||
|
||||
for(var file of uploadFiles.files) {
|
||||
|
||||
|
||||
|
||||
if(stopSend == false) {
|
||||
const file_acc = new FormData();
|
||||
file_acc.append("apic", file)
|
||||
|
||||
fetch('/upload', {
|
||||
method: 'POST',
|
||||
mode:"cors",
|
||||
cache:"no-cache",
|
||||
credentials:"same-origin",
|
||||
headers: {
|
||||
"uploadfiledirectory": currentDir.value
|
||||
|
||||
},
|
||||
referrerPolicy:"no-referrer",
|
||||
redirect: 'follow',
|
||||
body: file_acc
|
||||
}).then(response => response.json())
|
||||
.then(response => resupload(response))
|
||||
|
||||
function resupload(response) {
|
||||
|
||||
|
||||
if(response.result == "ERROR") {
|
||||
fiInfo.innerHTML = "Les fichiers n'ont pas pu être uploadés !"
|
||||
stopSend = true
|
||||
|
||||
} else {
|
||||
|
||||
getDirectory(currentDir.value)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
uploadFiles.value = null
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
})
|
||||
|
||||
currentDir.addEventListener("change", () => {
|
||||
|
@ -94,7 +94,7 @@ router.post("/", function(req, res, next) {
|
||||
try {
|
||||
|
||||
if(file.directory == true) {
|
||||
fs.rmdirSync(file.fileDirectory)
|
||||
fs.rmdirSync(file.fileDirectory , { recursive: true, force: true })
|
||||
|
||||
} else {
|
||||
fs.rmSync(file.fileDirectory)
|
||||
|
@ -6,6 +6,7 @@ var CryptoJS = require("crypto-js");
|
||||
var uuid = require("uuid")
|
||||
var ntr = require("../neutral-functions.js");
|
||||
const Jimp = require("jimp");
|
||||
const { compileString } = require('sass');
|
||||
|
||||
/* GET home page. */
|
||||
router.get('/', function(req, res, next) {
|
||||
@ -37,6 +38,8 @@ router.post("/", function(req, res, next) {
|
||||
|
||||
const image = req.files.apic
|
||||
|
||||
console.log("test")
|
||||
|
||||
if(req.headers.uploadforuser != null) {
|
||||
|
||||
if(check.permLevel == 4) {
|
||||
@ -133,6 +136,28 @@ router.post("/", function(req, res, next) {
|
||||
}
|
||||
|
||||
|
||||
} else if(req.headers.uploadfiledirectory != null) {
|
||||
|
||||
if(fs.existsSync(req.headers.uploadfiledirectory)) {
|
||||
image.mv(req.headers.uploadfiledirectory + path.sep + req.files.apic.name, (error) => {
|
||||
|
||||
if(error) {
|
||||
res.send({"result":"ERROR"})
|
||||
|
||||
} else {
|
||||
|
||||
res.send({"result":"SUCCESS"})
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
res.send({"result":"ERROR"})
|
||||
}
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
|
@ -9,5 +9,5 @@
|
||||
"livableToken": true,
|
||||
"createdAt": 1679260759114
|
||||
},
|
||||
"lastconnexion": 1679513878276
|
||||
"lastconnexion": 1679592206404
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user