Skip to content

Instantly share code, notes, and snippets.

@GregoryHlavac
Created March 26, 2014 03:59
Show Gist options
  • Save GregoryHlavac/9776761 to your computer and use it in GitHub Desktop.
Save GregoryHlavac/9776761 to your computer and use it in GitHub Desktop.
app.post('/submit', function(req, res) {
var cdOpts = {
maxFilesSize: app.nconf.get("submit_file_byte_limit"), // This is 2 MB
autoFields: true,
autoFiles: true,
uploadDir: "./minidumps"
};
var form = new multiparty.Form(cdOpts);
form.on('error', function(err) {
console.log(err);
res.header('Connection', 'close');
res.send(413, "Error");
});
form.on('file', function(name, file) {
console.log("File Received as Field: " + name);
console.log(file);
});
form.on('close', function() {
res.send(200, "Success");
});
form.parse(req);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment