In my case the user can select a file and click on the submit button. after submitting button I am showing the file as table format with file name, file size, download link and remove option. now my requirement is if user click on the download button from the table then the file should download. I don't want to upload file server side on a selection of files .
- var file = document.getElementById('documentfile').files[0];
- var filename = document.getElementById('documentfile').files[0].name;
- var size = document.getElementById('documentfile').files[0].size;
- var ext = $('#documentfile').val().split('.').pop().toLowerCase();
- var reader = new FileReader();
- var fileurl;
- reader.onload = function (e) {
- fileurl = e.target.result;
- }
- reader.readAsDataURL(file);
- var str = '
'1 ' + filename + ' ' + $('.sltdoctype').val() + ' ' + niceBytes(size) + ' + fileurl + ' download>download Remove - $('.document-table-str .table .tbody').append(str);
- $('.document-table-str').show();
- $('#documentfile').val("")

Ajay GuptaPosted Sep 17, 2018, 1:47 AM
Sukesh GandhamPosted Sep 14, 2018, 6:45 AM
$('a').click(function(e) { e.preventDefault(); //stop the browser from following window.location.href = 'uploads/file.doc'; }); Download now!