Skip to content

Instantly share code, notes, and snippets.

@ntanya
Created June 7, 2012 17:52
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 ntanya/2890392 to your computer and use it in GitHub Desktop.
Save ntanya/2890392 to your computer and use it in GitHub Desktop.
upload
app.post('/', function(req, res){
var temp_path = req.files.uploadfile.path;
var save_path = './public/images/' + req.files.uploadfile.name;
fs.rename(temp_path, save_path, function(error){
if(error) throw error;
fs.unlink(temp_path, function(){
if(error) throw error;
res.send("File uploaded to: " + save_path);
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment