Skip to content

Instantly share code, notes, and snippets.

@agreen757
Created February 5, 2015 16:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agreen757/680fe7e9369167b14153 to your computer and use it in GitHub Desktop.
Save agreen757/680fe7e9369167b14153 to your computer and use it in GitHub Desktop.
Jquery to initiate dowload from page
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