javascript - How to download a file from project/specific location using nodejs? -
this may dumb question lil confused, requirement should able download excel template on click event, thought put excel template in folder(docs) in backend code(instead of generating dynamically) , download that. possible, if yes how? using express , node.
it possible. use express framework. express can serve static files under '/public' folder. when user connect file, her/his browser download file. browser can view files online. example, chrome can open pdf files. if want force download file can use simple code;
app.get('/download', function(req, res){ var file = __dirname + '/upload-folder/dramaticpenguin.mov'; res.download(file); // set disposition , send it. });
Comments
Post a Comment