title: File API File Upload - Read XMLHttpRequest in ASP.NET MVC
body: <p>I am trying to implement Gmail style drag-and-drop file upload in ASP.NET MVC.</p>
  
  <p>I have been following this article: <a href="http://robertnyman.com/html5/fileapi-upload/fileapi-upload.html">http://robertnyman.com/html5/fileapi-upload/fileapi-upload.html</a> and want to post uploaded files to an MVC controller action.</p>
  
  <p>To do this, I modified the sample JavaScript script in the link to point to my controller action:</p>
  
  <pre><code>xhr.open("post", "/home/UploadFiles", true);
  </code></pre>
  
  <p>Here is my controller action:</p>
  
  <pre><code>[HttpPost]
  public virtual string UploadFiles(object obj)
  {
      var length = Request.ContentLength;
      var bytes = new byte[length];
      Request.InputStream.Read(bytes, 0, length);
      // var bytes has byte content here. what do do next?
  
      return "Files uploaded!";
  }
  </code></pre>
  
  <p>I set a breakpoint, and when I upload a file, the breakpoint gets hit - which is good. But how do I extract the data from the uploaded (javascript) XMLHttpRequest object? I don't think its in the HttpRequest - is it the parameter? If so, what type should i expect &amp; how do I extract the byte array and extract the uploaded file info from it?</p>
  
  <p>(I am using Chrome - I know it doesn't work in IE)</p>
  
  <p>Any suggestions would be greatly appreciated!</p>