Created
August 19, 2011 11:35
-
-
Save outbounder/1156621 to your computer and use it in GitHub Desktop.
This file contains 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
var formidable = require("formidable"); | |
var fs = require("fs"); | |
var form = new formidable.IncomingForm(), | |
files = [], | |
fields = []; | |
form.uploadDir = __dirname+"/uploads"; | |
form | |
.on('field', function(field, value) { | |
fields.push([field, value]); | |
}) | |
.on('file', function(field, file) { | |
files.push([field, file]); | |
}) | |
.on('end', function() { | |
response.writeHead(200, {'content-type': request.headers['content-type']}); | |
response.end(fs.readFileSync(files[0][1].path)); | |
}); | |
form.parse(request); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment