Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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);
Add Comment
Please, Sign In to add comment