title: How to download image from node server sending image filename in HTTP post request from Angular 2
body: <p>I want to download an image from node server when sending post request for image file name.But I couldn't get either save dialog box or direct download.I have a folder uploads from which I want to read the image and download.I am trying the code pasted over here.Please help me with a good solution.</p>
  
  <pre><code>    router.post('/download', urlencodedParser, function(req, res) {
      var img = path.resolve('uploads/' + req.body.file);
      var filename = path.basename(img);
      var mimetype = mime.lookup(img);
  
      console.log(filename);
      console.log(mimetype);
  
      res.setHeader('Content-disposition', 'attachment; filename=' + filename);
      res.setHeader('Content-type', mimetype);
  
      var filestream = fs.createReadStream(img);
      filestream.pipe(res);
  
      res.on('finish', function(){
          console.log("Download complete");
      });
  })
  </code></pre>