Commit fd5b06da authored by Lukas Böhm's avatar Lukas Böhm
Browse files

Update Upload.html

parent 4f66669f
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
$(".custom-file-input").on("change", function() { $(".custom-file-input").on("change", function() {
let fns = $(this)[0].files; let fns = $(this)[0].files;
let label = ""; let label = "";
for (var i = 0; i < fns.length; i++) { for (let i = 0; i < fns.length; i++) {
label = label.concat(fns[i].name); label = label.concat(fns[i].name);
if (i < fns.length - 1) label = label.concat(", "); if (i < fns.length - 1) label = label.concat(", ");
} }
...@@ -69,7 +69,7 @@ ...@@ -69,7 +69,7 @@
}); });
</script> </script>
<script> <script>
let share = {} let share = {};
function openShare() { function openShare() {
$.ajax({ $.ajax({
...@@ -83,11 +83,19 @@ ...@@ -83,11 +83,19 @@
}).done((response) => { }).done((response) => {
share = response; share = response;
disableAll(); disableAll();
uploadFile(); uploadFiles();
}); });
} }
function uploadFile() { function uploadFiles() {
for (file in $(".custom-file-input")[0].files) {
var formData = new FormData();
var request = new XMLHttpRequest();
formData.set('files', file);
request.open("POST", `http://localhost:6969/share/${ share.id }/attachments`);
request.send(formData);
}
closeShare(); closeShare();
} }
...@@ -100,8 +108,9 @@ ...@@ -100,8 +108,9 @@
"Content-Type": "application/json" "Content-Type": "application/json"
}, },
"data": JSON.stringify({}), "data": JSON.stringify({}),
}).done(() => { }).done((response) => {
window.location.href = "/d/" + share.id console.log(response);
{#window.location.href = "/d/" + share.id;#}
}); });
} }
</script> </script>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment