title: Uploading a file with XMLHttprequest - Missing boundary in multipart/form-data
body: <p>I'm uploading a file with XMLHttprequest.
  Here is the JS function, that uploads a file:</p>
  
  <pre><code>var upload = function(file) {
      // Create form data
      var formData = new FormData();
      formData.append('file', file);
  
      var xhr = new XMLHttpRequest();
  
      // Open
      xhr.open('POST', this.options.action);
  
      // Set headers
      xhr.setRequestHeader("Cache-Control", "no-cache");
      xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
      xhr.setRequestHeader("Content-Type", "multipart/form-data");
      xhr.setRequestHeader("X-File-Name", file.fileName);
      xhr.setRequestHeader("X-File-Size", file.fileSize);
      xhr.setRequestHeader("X-File-Type", file.type);
  
      // Send
      xhr.send(formData);
  }
  </code></pre>
  
  <p>On the server side, in <strong>upload.php</strong> I read the file this way:</p>
  
  <pre><code>file_put_contents($filename, (file_get_contents('php://input')));
  </code></pre>
  
  <p>Everything works fine, except that I get a PHP Warning: </p>
  
  <p><code>Missing boundary in multipart/form-data POST data in Unknown on line 0</code>.</p>
  
  <p>If I remove this line:
  <code>xhr.setRequestHeader("Content-Type", "multipart/form-data");</code> the warning goes away.</p>
  
  <p>What should be the problem here?</p>