title: How to add header data in XMLHttpRequest when using formdata?
body: <p>I'm trying to implement a file upload API, given here :
  <br>
  <a href="http://www.mediafire.com/developers/core_api/1.4/upload/#upload_top" rel="noreferrer">Mediafire file Upload</a></p>
  
  <p>I am successfully able to upload the <em>Post data</em> &amp; <em>Get data</em>, but have no clue how to send the <strong>x-filename</strong> attribute, which is meant to be <em>Header data</em> as given in API guide.</p>
  
  <p>My Code : </p>
  
  <pre><code>xmlhttp=new XMLHttpRequest();
  var formData = new FormData();
  
  formData.append("Filedata", document.getElementById("myFile").files[0]);
  
  var photoId = getCookie("user");
  // formData.append("x-filename", photoId);            //tried this but doesn't work
  // xmlhttp.setRequestHeader("x-filename", photoId);   //tried this too (gives error) [edited after diodeous' answer]
  
  xmlhttp.onreadystatechange=function()
  {
      alert("xhr status : "+xmlhttp.readyState);
  }
  
  var url = "http://www.mediafire.com/api/upload/upload.php?"+"session_token="+getCookie("mSession")+"&amp;action_on_duplicate=keep";
  
  xmlhttp.open("POST", url);
  // xmlhttp.setRequestHeader("x-filename", photoId);   //tried this too, doesnt work. Infact nothing gets uploaded on mediafire.  [edited after apsillers' answer]
  // cant get response due to same origin policy
  xmlhttp.send(formData);
  </code></pre>