Skip to content

Instantly share code, notes, and snippets.

@motiooon
Created May 15, 2012 19:18
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 motiooon/2704332 to your computer and use it in GitHub Desktop.
Save motiooon/2704332 to your computer and use it in GitHub Desktop.
/**
* User RESTful Routes
*/
var _ = require("underscore"),
helpers = require(".././helpers"),
fs = require("fs");
module.exports = function (app) {
app.post("/photos", helpers.ensureAuthenticated, function(req, res){
fs.readFile(req.files.displayImage.path, function (err, data) {
// ...
console.log(req.files.displayImage);
var newPath = __dirname + '/uploads/uploadedFileName.png';
fs.writeFile(newPath, data, function (err) {
if(err) {throw err;}
console.log(newPath);
res.redirect("back");
});
});
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment