Thursday 20 April 2017

I am trying to create a Download Button but file is not downloading?

I am creating download button having click listener which request server to download file

code click listener:

 downloadFileClick(event){
   $.ajax('/download', {data:{}}).done(function(data){

   }.bind(this));
 }

at server side following code is running

app.get('/download', function(req, res){
  var file = __dirname + '/write/imageout.png';
  res.download(file);
});

file is not downloading in browser. I checked response send from server to client it sending file content but it not downloading from browser.



via AviatorX

No comments:

Post a Comment