Client side - Implement Uploads

This commit is contained in:
2019-05-27 15:07:36 +05:30
parent 0c428a2b33
commit d8c6001d90
3 changed files with 22 additions and 3 deletions

View File

@@ -12,7 +12,7 @@ Dependencies(testing): `chai` `mocha` `chai-http`
- [x] Folder Traversal - [x] Folder Traversal
- [X] File Downloads - [X] File Downloads
- [X] File Moving - [X] File Moving
- [ ] Upload - [X] Upload
### Why ### Why

View File

@@ -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")
})
})
}) })

View File

@@ -23,8 +23,8 @@
<div class="window-button done-upload"><span class="far fa-check-circle"></span></div> <div class="window-button done-upload"><span class="far fa-check-circle"></span></div>
<div class="window-button close-upload"><span class="far fa-times-circle"></span></div> <div class="window-button close-upload"><span class="far fa-times-circle"></span></div>
<form enctype="multipart/form-data" id="upload-form"> <form enctype="multipart/form-data" id="upload-form">
<input hidden='true' type="value" name="loc" /> <input hidden='true' type="value" name="loc" id="upload-directory"/>
<label for="fileInput">Upload file</label> <label for="fileInput" id="fileLabel">Upload file</label>
<input type='file' name="fileUpload" id="fileInput" /> <input type='file' name="fileUpload" id="fileInput" />
</form> </form>
</div> </div>