0

I have created a servlet which displays all the files within a folder (present on server). The filenames displayed are all displayed in the form of links (using a href), so as to facilitate file download.

But when i click on the FileXYZ link, i want to download file, but unable to download. I am using:

function downloadfile(file){
var blob = new Blob(['\ufeff'], {type: 'application/vnd.ms-excel'});
window.navigator.msSaveOrOpenBlob(blob, fileName);
}

<a href="javascript:void(0);" onclick=downloadfile(file);>FileXYZ<a>

I think the 1st parameter ('\ufeff') of Blob object is not correct. What should that be ?

Curious89
  • 63
  • 1
  • 6
  • Does this solve your problem: https://stackoverflow.com/questions/3749231/download-file-using-javascript-jquery – Bjop Feb 04 '22 at 06:34
  • Thanks for the link, but the file that I wish to download is present on server. This link I think talks about downloading file not present on server. – Curious89 Feb 15 '22 at 10:49

0 Answers0