Created
January 23, 2011 20:39
-
-
Save mraleph/792420 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 https = require('https'); | |
var fs = require('fs'); | |
var util = require('util'); | |
var sys = require('sys'); | |
https.createServer({ | |
key: fs.readFileSync('some.key'), cert: fs.readFileSync('some.crt') | |
}, function(rq, rs) { | |
if (rq.url == '/upload' && rq.method.toLowerCase() == 'post') { | |
rq.on('data', function (buffer) { | |
rq.pause(); | |
console.log("data: " + buffer.length); | |
process.nextTick(function () { rq.resume(); }); | |
}); | |
rq.on('error', function (error) { console.log("error: " + error); }); | |
rq.on('end', function () { | |
console.log("end"); | |
rs.writeHead(200, {'content-type': 'text/html'}); | |
rs.end( | |
'<form action="/upload" enctype="multipart/form-data" method="post">'+ | |
'<input type="file" name="upload" multiple="multiple"><br>'+ | |
'<input type="submit" value="Upload">'+ | |
'</form>' | |
); | |
rs.end(); | |
}); | |
return; | |
} | |
// show a file upload form | |
rs.writeHead(200, {'content-type': 'text/html'}); | |
rs.end( | |
'<form action="/upload" enctype="multipart/form-data" method="post">'+ | |
'<input type="file" name="upload" multiple="multiple"><br>'+ | |
'<input type="submit" value="Upload">'+ | |
'</form>' | |
); | |
}).listen(8443); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment