File Downloading

This commit is contained in:
2019-05-24 14:41:30 +05:30
parent 464c6c1c3f
commit a87092d3e8
5 changed files with 52 additions and 17 deletions

View File

@@ -1,15 +1,16 @@
let currDir = {'loc':'','contents':null};
let currSel = {'loc':'','path':''}
let currDir = {'loc':'','contents':null}
let currSel = {'loc':null,'name':null}
function doUpdate(ele,isDir=false){
//console.log(ele.attr('data-choice'));
if(ele.hasClass('file-isDir')){
currDir.loc = ele.attr('data-choice');
currDir.loc = ele.attr('data-choice')
populateContents();
}
if(!isDir){
$('.nav-bottom-text').html(ele.html())
currSel.loc = ele.attr('data-choice')
$('.nav-bottom-text').html(currSel.name = ele.html())
}
//$()
@@ -57,5 +58,21 @@ function populateContents(){
$(document).ready(()=>{
populateContents();
//updateContents();
$('.file-download-button').click(()=>{
console.log(currSel)
$.ajax('/files/cat',{
method:'post',
data:currSel,
xhrFields: {
responseType: 'blob'
},
success:(msg)=>{
//console.log(msg)
$('.file-download-button').after(`<a id="down-temp" href="${window.URL.createObjectURL(msg)}" download="${currSel.name}"></a>`)
document.getElementById('down-temp').click()
$('#down-temp').remove();
},
error: err=>console.log(err)
})
})
})