• I had some code for handling multipart form data here if it helps:

    var fileNo = 0;
    
    function onPageRequest(req, res) {
      var d = "";
      var boundary;
      var f;
      req.on('close', function() { 
        if (f) {
          f.close();
          console.log("File uploaded");
        }
      });
      req.on('data', function(data) { 
        d += data;
        if (f) {
          var idx = d.indexOf(boundary);
          /* ensure we always leave some in our buffer
          in case boundary straddles packets */
          if (idx>=0) {
            console.log("Boundary found - starting again");
            f.write(d.substring(0, idx));
            f.close();
            f = undefined;
          } else {
            idx = d.length-boundary.length; 
            f.write(d.substring(0, idx));
          }
          d = d.substring(idx);
        } else {
          var idx = d.indexOf("\r\n\r\n");
          if (idx>=0) {
            var header = d.substring(0,idx).split("\r\n");
            boundary = "\r\n"+header.shift();
            header = header.map(function(x){return x.split(": ");});
            console.log(JSON.stringify(header));  
            // choose a filename
            var fileName = "f"+fileNo+".txt";
            console.log("Writing to "+fileName);
            f = E.openFile(fileName, "w");
            fileNo++;
            d = d.substring(idx+4);
          }
        }
      });
      res.writeHead(200, {'Content-Type': 'text/html'});
      res.write('<html><body><form method="post" enctype="multipart/form-data">');
      res.write('<input type="file" name="file1" id="file"><input type="file" name="file2" id="file"><input type="submit">');
      res.end('</form></body></html>');
    }
    require('http').createServer(onPageReque­st).listen(8080);
    
About

Avatar for Gordon @Gordon started