Skip to content

Instantly share code, notes, and snippets.

@mraleph
Created January 23, 2011 20:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mraleph/792420 to your computer and use it in GitHub Desktop.
Save mraleph/792420 to your computer and use it in GitHub Desktop.
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