Skip to content

Instantly share code, notes, and snippets.

@airtheva
Last active August 29, 2015 14:01
Show Gist options
  • Save airtheva/a8517366fbae1dc8f41a to your computer and use it in GitHub Desktop.
Save airtheva/a8517366fbae1dc8f41a to your computer and use it in GitHub Desktop.
// An example of recovering the old taste of req.files under Express 4.
var app = require('express')();
app.use(require('body-parser')());
// As body-parser won't parse multipart/form-data, we use connect-multiparty to do this.
// There are some other alternatives, for example, formidable, busboy, and multiparty, etc.
app.use(require('connect-multiparty')());
app.post('/', function(req, res) {
res.end(JSON.stringify(req.files, null, 4));
});
app.listen(12345);
console.log('express is running at 127.0.0.1:12345.');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment