Skip to content

Instantly share code, notes, and snippets.

@bbeaumont
Created July 1, 2013 22:28
Show Gist options
  • Save bbeaumont/5905193 to your computer and use it in GitHub Desktop.
Save bbeaumont/5905193 to your computer and use it in GitHub Desktop.
simple form upload
/*
* GET home page.
*/
var fs = require('fs');
exports.thing = function (req, res) {
res.render('testform', { title: 'Test form' });
};
exports.submitform = function(req,res) {
console.log(req.files);
fs.readFile(req.files.jsonfile.path, function (err, data) {
// ...
var newPath = __dirname + "./uploaded.json";
fs.writeFile(newPath, data, function (err) {
res.redirect("back");
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment