0

I'm using express to create a link where users download a file. Once click the link, the file downloads to their computer.

For that I'm using:

res.download('filename.pdf');

Easy.

Is is possible to either redirect them to another page or send an html page along as well? Not sure web servers can even do this.

wesbos
  • 25,839
  • 30
  • 106
  • 143
  • 2
    I haven't tried specifically in node, but usually you have to do it the other way - go to the landing page then trigger the download from there. http://stackoverflow.com/questions/822707/php-generate-file-for-download-then-redirect/822732#822732 – lemieuxster May 29 '14 at 21:17

1 Answers1

0

No.

In the future, I think you could pull this off with SPDY or HTTP 2.0, but HTTP 1.1 doesn't allow this. Technically you can attach data to a 302 moved response, but the browser is just going to ignore it.

wmil
  • 3,179
  • 2
  • 21
  • 24