From d8c6001d902f97f8e8b06752c2903babc72759c3 Mon Sep 17 00:00:00 2001 From: Christopher Rose Date: Mon, 27 May 2019 15:07:36 +0530 Subject: [PATCH] Client side - Implement Uploads --- README.md | 2 +- static/base.js | 19 +++++++++++++++++++ static/index.html | 4 ++-- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ac21577..c54a4f3 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Dependencies(testing): `chai` `mocha` `chai-http` - [x] Folder Traversal - [X] File Downloads - [X] File Moving -- [ ] Upload +- [X] Upload ### Why diff --git a/static/base.js b/static/base.js index e3fe639..ed2ecec 100644 --- a/static/base.js +++ b/static/base.js @@ -125,4 +125,23 @@ $(document).ready(()=>{ }) } }) + $("#fileInput").change((e)=>{ + console.log(e.target.files) + $("#fileLabel").html(e.target.files[0].name); + }) + $(".done-upload").click(()=>{ + $("#upload-directory").val(currDir.loc) + //$("#theForm").ajaxSubmit({url: '/files/upload', type: 'post'}) + $.ajax("/files/upload",{ + method: 'post', + processData:false, + contentType:false, + data:new FormData(document.getElementById('upload-form')), + success:msg=>{ + alert(msg.done) + closeUploadWindow(); + }, + error:msg=>alert("Error") + }) + }) }) diff --git a/static/index.html b/static/index.html index 20c7111..6d87f99 100644 --- a/static/index.html +++ b/static/index.html @@ -23,8 +23,8 @@
- - + +