Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

7
  • 4
    Thanks.. Is there a way to get this information from the fs.readFileSync? I'm using a static file in this example but I'll use this download api for any files, passing the name of it. Commented Sep 2, 2011 at 20:33
  • Setting output filename works with res.setHeader('Content-disposition', 'attachment; filename=' + filename); tnx! Commented Jan 21, 2013 at 5:31
  • 8
    Express 4.x uses .set() instead of .setHeader() btw Commented Mar 17, 2016 at 19:37
  • if you pass in the path, is this method safe for directory traversal attacks? Commented Jul 24, 2018 at 0:00
  • @MikeSchem It is not. Commented Jul 24, 2018 at 0:46