Created
February 5, 2015 16:36
-
-
Save agreen757/680fe7e9369167b14153 to your computer and use it in GitHub Desktop.
Jquery to initiate dowload from page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Front-end | |
--------- | |
$('<form action="'+ "/templatedl" +'" method="'+ ('post') +'">'+'<input type="hidden" name="file" value="'+filename+'"'+'/></form>').appendTo('body').submit().remove(); | |
Back-end | |
--------- | |
app.post('/templatedl',function(req,res){ | |
res.download(__dirname +'/'+ name+'.extension', function(err){ | |
if(err){console.log(err)} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment