title: fileupload with Formdata ajax and busboy
body: <p>I would like to upload files with ajax using the html5 file API, but I've troubles saving the file on the serverside ( node.js )</p>
  
  <p>I'm using busboy but busboy doesn't trigger a file event, just a field event.</p>
  
  <p>clientside:</p>
  
  <pre><code>upload.prototype.sendFile = function(fileData){
    var formData = new FormData()
    formData.append('test.jpg',fileData)
    var xhr = new XMLHttpRequest();
    xhr.open("post", "/file/upload", true);
    xhr.send(formData)
  }
  </code></pre>
  
  <p>serverside:</p>
  
  <pre><code>app.post('/file/upload',function(req,res,next){
    var busboy = new Busboy({ headers: req.headers });
    busboy.on('file', function(fieldname, file, filename, encoding, mimetype) {
      console.log('File [' + fieldname + ']: filename: ' + filename + ', encoding: ' + encoding + ', mimetype: ' + mimetype);
      file.on('data', function(data) {
        console.log('File [' + fieldname + '] got ' + data.length + ' bytes');
      });
      file.on('end', function() {
        console.log('File [' + fieldname + '] Finished');
      });
    });
    busboy.on('field', function(fieldname, val, fieldnameTruncated, valTruncated, encoding, mimetype) {
      console.log('Field [' + fieldname + ']: value: ' + inspect(val));
    });
    busboy.on('finish', function() {
      console.log('Done parsing form!');
      res.writeHead(303, { Connection: 'close', Location: '/' });
      res.end();
    });
    req.pipe(busboy);
  })
  </code></pre>