diff options
author | Alex Vitkov <alexvitkov98@gmail.com> | 2021-02-12 12:39:04 +0200 |
---|---|---|
committer | Alex Vitkov <alexvitkov98@gmail.com> | 2021-02-12 12:39:04 +0200 |
commit | dfcfc5da50c86a936124e820530cb72c93fc1a17 (patch) | |
tree | 1752b35ddee7fb4ec6890dd51d6ff423fb17ed0b /loggedin.js | |
parent | ed66392fc694ffb10b59a22b9305c7334d13a67f (diff) | |
parent | 76d480420f611c09625e947f0f0ed496c79f2ce9 (diff) | |
download | fileup-dfcfc5da50c86a936124e820530cb72c93fc1a17.tar.gz |
Merge branch 'live'
Diffstat (limited to 'loggedin.js')
-rw-r--r-- | loggedin.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/loggedin.js b/loggedin.js new file mode 100644 index 0000000..8980586 --- /dev/null +++ b/loggedin.js @@ -0,0 +1,28 @@ +const upload_form = document.getElementById("upload_form"); +const the_file = document.getElementById("the_file"); +const filename_input = document.getElementById("filename"); +const upload_btn = document.getElementById("upload_btn"); + +the_file.onchange = on_file_added; + +function on_file_added(e) { + if (the_file.files.length >= 1) { + filename_input.value = the_file.files[0].name; + + // Send the form asynchronously through the fetch api + fetch(upload_form.action, { + method: upload_form.method, + body: new FormData(upload_form) + }) + + alert("Sent the upload request"); + } + else { + alert("No files selected"); + } + +} + +function begin_upload() { + the_file.click(); +} |