Created
December 29, 2013 18:49
-
-
Save dariusc93/8173472 to your computer and use it in GitHub Desktop.
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
module.exports = { | |
index:function(req,res){//get /test in routes.js | |
res.view('test'); | |
}, | |
upload:function(req,res){//post /upload in routes.js | |
console.log(req.files.uploadfile); | |
var path = '/home/projects/upload/'+req.files.uploadfile.name; | |
require('fs').rename(req.files.uploadfile.path,path,function(err){ | |
if(err) throw err; | |
fs.chmodSync(path,440);//for *nix systems | |
res.redirect('/test'); | |
}); | |
}, | |
_config: {} | |
}; |
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
doctype html | |
html | |
head | |
title File Upload | |
body | |
form(action='/upload',method='post',enctype='multipart/form-data') | |
input(type='file',name='uploadfile') | |
input(type='hidden', name='_csrf', value='#{_csrf}') | |
button(type='submit') Upload |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm probably missing something really dumb, the file upload appears to be successful but the file isn't on the server.