Created
July 1, 2013 22:28
-
-
Save bbeaumont/5905193 to your computer and use it in GitHub Desktop.
simple form upload
This file contains hidden or 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
/* | |
* 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