title: Why content of the MultipartHttpServletRequest is empty?
body: <p>I'm trying to upload 2 documents using AngularJs. The user fills the information like Name, Date of Birth, Gender etc. If these data successfully stored in the database through spring controller, 2 documents should be stored.</p>
  
  <p><strong>JS</strong></p>
  
  <p>Below code is for adding and removing the documents.</p>
  
  <pre><code>$scope.items = [];
  $scope.item = {};
  
  $scope.addItem = function (item)
      {   
            if ($scope.item.file != undefined){
                $scope.items.push( $scope.item);
                $scope.item = {};
            }
            else {
                alert("Please open a file before adding");
               }
       }
  $scope.removeItem = function (item)
      {
           for (var i = 0; i &lt; $scope.items.length; i++)
              {
                   if ($scope.items[i] === item)
                      {
                              $scope.items.splice(i, 1);
                              break;
                              }
              }
      }
  </code></pre>
  
  <p>Below code is for submitting the form data and documents.</p>
  
  <pre><code>$scope.submit = function()
       { 
           var formData =
                  {
                      fullName     : $scope.fullName,
                      fatherName   : $scope.fatherName,
                      gender       : $scope.gender,
                      contactNumber: $scope.contactNumber,
                      dateofbirth  : $scope.dateofbirth,
                      subDate      : new Date()
                  };
  
          $http.post('userdetails', formData ).success(function(response)
              {
                  if ($scope.items.length &gt; 0)
                      {
                          for (var i = 0 ; i &lt; $scope.items.length ; i++)
                            {
                                  $scope.uploadItem(response.id, $scope.items[i]);
                            }
                      }  
  
              }).error(function(error)
                              {
                                  alert(error);
                              });
  
      };
  
  $scope.uploadItem = function(id, file)
  {
         var data = new FormData();
         data.append('id', id);
         data.append('file', file);
  
         $http.post('multipleSave', data, {
               headers: { 'Content-Type': undefined,
                          enctype:'multipart/form-data' }
  
                       }).success(function(data) {
                          $log.debug("Upload Successfull");
  
                      }).error(function(error) {
                           $log.debug("Upload failure");
                       });
   };
  </code></pre>
  
  <p>First form data would be stored and if it is success, Documents should be passed. Here id is auto generated which is returned in response from the database after storing the form data. All these happen in one click from front end.</p>
  
  <p><strong>Spring Controller</strong></p>
  
  <pre><code>@RequestMapping(value = "/multipleSave", method = RequestMethod.POST)
  
  public @ResponseBody void uploadFile(MultipartHttpServletRequest request, HttpServletResponse response) throws IOException {
  
          Iterator&lt;String&gt; fileName=request.getFileNames();
          MultipartFile file= request.getFile(fileName.hasNext());
          System.out.println("file");
  }
  </code></pre>
  
  <p><strong>In Spring Configuration</strong></p>
  
  <pre><code>&lt;bean id="multipartResolver"
      class="org.springframework.web.multipart.commons.CommonsMultipartResolver"&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>I ran in debugging mode and I saw that content of MultipartHttpServletRequest is empty. It is not receiving any file.
  Any help on this?</p>