Switch to GET, fix forms

GET is much more better than using blobs
This commit is contained in:
2019-05-25 13:37:19 +05:30
parent 57a43aa643
commit aa46296f53
6 changed files with 66 additions and 8 deletions

View File

@@ -20,6 +20,15 @@ input[type="text"]{
border:1px gray solid;
width:5rem;
}
input[type="file"]{
display:none;
}
label[for="fileUpload"]{
padding:0.5rem;
border:1px gray solid;
}
.window{
width:15rem;

View File

@@ -60,12 +60,26 @@ $(document).ready(()=>{
populateContents();
$('.file-download-button').click(()=>{
console.log(currSel)
$.ajax('/files/cat',{
/*$.ajax('/files/cat',{
method:'post',
data:currSel,
xhrFields: {
responseType: 'blob'
},
xhr:()=>{
var xhr = new XMLHttpRequest();
xhr.addEventListener('progress',(ev)=>{
//console.log([ev.loaded,ev.total,ev.lengthComputable])
if(ev.lengthComputable){
$('.file-download-percent').html(`${Math.round(100*ev.loaded/ev.total)}%`)
}
})
xhr.upload.addEventListener('error',(ev)=>{
$('.file-download-percent').html('F')
})
return xhr
},
success:(msg)=>{
//console.log(msg)
$('.file-download-button').after(`<a id="down-temp" href="${window.URL.createObjectURL(msg)}" download="${currSel.name}"></a>`)
@@ -73,7 +87,10 @@ $(document).ready(()=>{
$('#down-temp').remove();
},
error: err=>console.log(err)
})
})*/
$('.file-download-button').after(`<a id="down-temp" href="/files/cat?loc=${currSel.loc}" download="${currSel.name}"></a>`)
document.getElementById('down-temp').click()
$('#down-temp').remove();
})
$('.close-rename').click(()=>{
$('.rename-window').fadeOut('fast')

View File

@@ -20,6 +20,10 @@
<div class="upload-window window box-shadow-2 hidden">
<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>
<form enctype="multipart/form-data">
<label for="fileInput">Upload file</label>
<input type='file' name="fileUpload" id="fileInput" />
</form>
</div>
</div>
<div class="navbar-container box-shadow-1">
@@ -54,6 +58,7 @@
Select file
</span>
<span class="icon-tabs">
<span class="file-download-percent"></span>
<span class="file-download-button" alt="Download">
<span class="fas fa-file-download"></span>
</span>