title: Asp.net Core rc2 web api file upload
body: <p>Need help, how I can upload file in ASP.NET core rc2 web api.
  When i use asp.net 4.5 it working with this code: </p>
  
  <pre><code>   @{
  ViewBag.Title = "Home Page";
      }
  
   &lt;div&gt;
  &lt;input type="file" name="upload" id="uploadFile"  /&gt;&lt;br /&gt;
  &lt;button id="submit"&gt;Загрузить&lt;/button&gt;
  &lt;/div&gt;
  
   @section scripts{
  &lt;script type="text/javascript"&gt;
  
  $('#submit').on('click', function (e) {
      e.preventDefault();
      var files = document.getElementById('uploadFile').files;
      if (files.length &gt; 0) {
          if (window.FormData !== undefined) {
              var data = new FormData();
              for (var x = 0; x &lt; files.length; x++) {
                  data.append("file" + x, files[x]);
              }
  
              $.ajax({
  type: "POST",
  url: 'api/values/post',
  contentType: false,
  processData: false,
  data: data,
  success: function (result) {
      alert(result);
  },
  error: function (xhr, status, p3) {
      alert(status);
  }
  });
          } else {
              alert("Браузер не поддерживает загрузку файлов HTML5!");
          }
      }
  });
  </code></pre>
  
  <p>
      }</p>
  
  <pre><code>public class ValuesController : ApiController
  {
  public async Task&lt;IHttpActionResult&gt; Post()  
  {
      if (!Request.Content.IsMimeMultipartContent())
      {
          return BadRequest();
      }
      var provider = new MultipartMemoryStreamProvider();
      // путь к папке на сервере
      string root = System.Web.HttpContext.Current.Server.MapPath("~/Files/");
      await Request.Content.ReadAsMultipartAsync(provider);
  
      foreach (var file in provider.Contents)
      {
          var filename = file.Headers.ContentDisposition.FileName.Trim('\"');
          byte[] fileArray = await file.ReadAsByteArrayAsync();
  
          using (System.IO.FileStream fs = new System.IO.FileStream(root + filename, System.IO.FileMode.Create))
          {
              await fs.WriteAsync(fileArray, 0, fileArray.Length);
          }
      }
      return Ok("файлы загружены");
  }
  }
  </code></pre>
  
  <p>Now, in asp.net core rc2 it doesnt work, If use IFromFile in mvc without ajax it works, but we use js+ajax+webapi</p>