mirror of
https://github.com/gmemstr/sliproad.git
synced 2024-09-20 00:21:15 +01:00
Actually add js file for file drag and drop.
This commit is contained in:
parent
c252f1bf77
commit
a3d421ed3d
40
assets/web/static/fileListing.js
Normal file
40
assets/web/static/fileListing.js
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
function dragEnter(e) {
|
||||||
|
document.getElementById("uploadoverlay").classList.remove("hidden");
|
||||||
|
}
|
||||||
|
|
||||||
|
function dragExit(e) {
|
||||||
|
document.getElementById("uploadoverlay").classList.add("hidden");
|
||||||
|
}
|
||||||
|
document.addEventListener("drop", function(e) {
|
||||||
|
var files = e.target.files || e.dataTransfer.files
|
||||||
|
console.log(files)
|
||||||
|
document.getElementById("uploadoverlay").classList.add("hidden");
|
||||||
|
for (var i = 0; i <= files.length; i++) {
|
||||||
|
upload(files[i]);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
window.addEventListener("dragover",function(e){
|
||||||
|
e = e || event;
|
||||||
|
e.preventDefault();
|
||||||
|
},false);
|
||||||
|
window.addEventListener("drop",function(e){
|
||||||
|
e = e || event;
|
||||||
|
e.preventDefault();
|
||||||
|
},false);
|
||||||
|
|
||||||
|
|
||||||
|
var upload = (file) => {
|
||||||
|
var clkepath = document.getElementById("path").value;
|
||||||
|
var formData = new FormData();
|
||||||
|
formData.append("path", path);
|
||||||
|
formData.append("file", file);
|
||||||
|
fetch('/upload', { // Your POST endpoint
|
||||||
|
method: 'POST',
|
||||||
|
body: formData
|
||||||
|
}).then(
|
||||||
|
success => console.log(success) // Handle the success response object
|
||||||
|
).catch(
|
||||||
|
error => console.log(error) // Handle the error response object
|
||||||
|
);
|
||||||
|
};
|
5
assets/web/static/svgs/newfile.svg
Normal file
5
assets/web/static/svgs/newfile.svg
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 24 24" fill="none" stroke="#ffffff"
|
||||||
|
stroke-width="1" stroke-linecap="butt" stroke-linejoin="round">
|
||||||
|
<path d="M20 11.08V8l-6-6H6a2 2 0 0 0-2 2v16c0 1.1.9 2 2 2h6"/>
|
||||||
|
<path d="M14 3v5h5M18 21v-6M15 18h6"/>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 300 B |
Loading…
Reference in a new issue