When I download a file, it gets downloaded to my project directory and not my downloads folder. There is also no prompt when clicking the download so it also doesn't get downloaded to the users machine, just the server's folder
router
router.get('/download', function(req, res) {
getFile(req, res);
res.redirect('/');
});
function getFile(req,res) {
var file = fs.createWriteStream("file.jpg");
var request = http.get("http://i3.ytimg.com/vi/J---aiyznGQ/mqdefault.jpg", function(response) {
response.pipe(file);
});
}
HTML
<form method="get" action="/download">
<button type="submit">download</button>
</form>