title: File upload does not always work in AngularJS
body: <p>I am using the AngularJS file upload from (<a href="https://github.com/nervgh/angular-file-upload" rel="nofollow">https://github.com/nervgh/angular-file-upload</a>) and it does not consistently work for the same file over and over.  Not sure it is in the AngularJS code or my REST API code.</p>
  
  <p>My controller code -</p>
  
  <pre><code>[Route("uploadFile")]
  [HttpPost]
  public void UploadFile()
  {
      var httpPostedFile = HttpContext.Current.Request.Files["file"];
      var folderExists = Directory.Exists(HttpContext.Current.Server.MapPath("~/UploadedDocuments"));
      if (!folderExists)
          Directory.CreateDirectory(HttpContext.Current.Server.MapPath("~/UploadedDocuments"));
      if (httpPostedFile != null)
      {
          var fileSavePath = Path.Combine(HttpContext.Current.Server.MapPath("~/UploadedDocuments"), httpPostedFile.FileName);
          httpPostedFile.SaveAs(fileSavePath);
      }
  }
  </code></pre>
  
  <p>My AngularJS controller -</p>
  
  <pre><code>var uploader = $scope.uploader = new FileUploader({
      url: apiUrl.serviceBase + "api/quotes/uploadFile"
  });
  uploader.onSuccessItem = function (fileItem) {
      $scope.uploader.queue = [];
      $scope.uploader.progress = 0;
      alert("Selected file has been uploaded successfully.");
      vm.file.fileName = fileItem.file.name;
      vm.file.originatedBy = vm.userName;
      vm.file.modifiedBy = vm.userName;
      vm.file.rfq = vm.rfq;
      quotesService.updateFile(vm.file).then(processSuccess, processError);
      $location.path("/quotes");
  };
  
  uploader.onErrorItem = function () {
      alert("We were unable to upload your file. Please try again.");
  };
  </code></pre>
  
  <p>My HTML code -</p>
  
  <pre><code>                &lt;tbody&gt;
                      &lt;tr ng-repeat="item in uploader.queue"&gt;
                          &lt;td&gt;&lt;strong&gt;{{ item.file.name }}&lt;/strong&gt;&lt;/td&gt;
                          &lt;td ng-show="uploader.isHTML5" nowrap&gt;{{ item.file.size/1024/1024|number:2 }} MB&lt;/td&gt;
                          &lt;td ng-show="uploader.isHTML5"&gt;
                              &lt;div class="progress" style="margin-bottom: 0;"&gt;
                                  &lt;div class="progress-bar" role="progressbar" ng-style="{ 'width': item.progress + '%' }"&gt;&lt;/div&gt;
                              &lt;/div&gt;
                          &lt;/td&gt;
                          &lt;td class="text-center"&gt;
                              &lt;span ng-show="item.isSuccess"&gt;&lt;i class="glyphicon glyphicon-ok"&gt;&lt;/i&gt;&lt;/span&gt;
                              &lt;span ng-show="item.isCancel"&gt;&lt;i class="glyphicon glyphicon-ban-circle"&gt;&lt;/i&gt;&lt;/span&gt;
                              &lt;span ng-show="item.isError"&gt;&lt;i class="glyphicon glyphicon-remove"&gt;&lt;/i&gt;&lt;/span&gt;
                          &lt;/td&gt;
                          &lt;td nowrap&gt;
                              &lt;button type="button" class="btn btn-success btn-xs" ng-click="item.upload()" ng-disabled="item.isReady || item.isUploading || item.isSuccess"&gt;
                                  &lt;span class="glyphicon glyphicon-upload"&gt;&lt;/span&gt; Upload
                              &lt;/button&gt;
                              &lt;button type="button" class="btn btn-warning btn-xs" ng-click="item.cancel()" ng-disabled="!item.isUploading"&gt;
                                  &lt;span class="glyphicon glyphicon-ban-circle"&gt;&lt;/span&gt; Cancel
                              &lt;/button&gt;
                              &lt;button type="button" class="btn btn-danger btn-xs" ng-click="item.remove()"&gt;
                                  &lt;span class="glyphicon glyphicon-trash"&gt;&lt;/span&gt; Remove
                              &lt;/button&gt;
                          &lt;/td&gt;
                      &lt;/tr&gt;
                  &lt;/tbody&gt;
              &lt;/table&gt;
  </code></pre>
  
  <p>I am not sure where the error is, sometimes it never gets to the REST API.  The way that I am testing is trying to load the same file over and over again.  Do I have to do something after I call the saveas function?</p>