Skip to content

Instantly share code, notes, and snippets.

@markdaws
Created February 27, 2012 02:24
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 markdaws/1920845 to your computer and use it in GitHub Desktop.
Save markdaws/1920845 to your computer and use it in GitHub Desktop.
app.post('/api/photos', function(req, res) {
var serverPath = '/images/' + req.files.userPhoto.name;
require('fs').rename(
req.files.userPhoto.path,
'/Users/mark/code/examples/file-upload/upload-example-app/public' + serverPath,
function(error) {
if(error) {
res.send({
error: 'Ah crap! Something bad happened'
});
return;
}
res.send({
path: serverPath
});
}
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment