title: angularjs spring rest file upload form
body: <p>I made angularjs spring rest file upload by the following code it works well and save file ,now I want to add some input text like  description to html form with file upload and save them What is the code I should add to formData() in angular controller to make this?</p>
  
  <p>angularjs controller</p>
  
  <pre><code>var myDropzone = new Dropzone("div#file", 
                  { url: "#"
                  });
              myDropzone.on("addedfile", function(file) {
                   $scope.file=file; 
  
              });
       $scope.uploadFile=function(){
          var formData=new FormData();
          formData.append("file",$scope.file);
          console.log(formData)
          $http.post('/pagingpoc/app/newDocument', formData, {
              transformRequest: function(data, headersGetterFunction) {
                  return data;
              },
              headers: { 'Content-Type': undefined }
              }).success(function(data, status) {                       
                  console.log("Success ... " + status);
              }).error(function(data, status) {
                  console.log("Error ... " + status);
              });
          $('#saveAttachmentModal').modal('hide');
    };
  </code></pre>
  
  <p>html form</p>
  
  <pre><code>  &lt;form ng-submit="uploadFile()"  enctype="multipart/form-data"&gt;
  
          &lt;div class="form-group"&gt;
            &lt;label&gt;Description&lt;/label&gt;
            &lt;textarea rows="5" cols="5" ng-model="description"&gt;&lt;/textarea&gt;&lt;br&gt;
          &lt;/div&gt;
  
          &lt;div  id="file" class="dropzone"&gt;&lt;/div&gt;
          &lt;div class="modal-footer"&gt;
           &lt;button type="button" class="btn btn-default" 
                     data-dismiss="modal" ng-click="clear()"&gt;
                &lt;span class="glyphicon glyphicon-ban-circle"&gt;&lt;/span&gt; Cancel
                          &lt;/button&gt;
            &lt;button type="submit"  class="btn btn-primary"&gt;
                        &lt;span class="glyphicon glyphicon-save"&gt;&lt;/span&gt; Save
                          &lt;/button&gt;
          &lt;/div&gt; 
       &lt;/form&gt;
  </code></pre>
  
  <p>Rest Controller</p>
  
  <pre><code>      public void UploadFile(MultipartHttpServletRequest request,
                  HttpServletResponse response) throws IOException {
  
          Attachment attachment=new Attachment();
          Iterator&lt;String&gt; itr=request.getFileNames();
          MultipartFile file=request.getFile(itr.next());
          String fileName=file.getOriginalFilename();
          attachment.setName(fileName);
          attachmentRepository.save(attachment);
          File dir = new File("/home/ali/");
           if (dir.isDirectory())
           {
              File serverFile = new File(dir,fileName);
             BufferedOutputStream stream = new BufferedOutputStream(
                   new FileOutputStream(serverFile));
             stream.write(file.getBytes());
             stream.close();
         }else {
          System.out.println("Error Found");
        }
  
   }
  </code></pre>