title: File upload is not working in spring using jquery-ajax
body: <p>This is my form : </p>
  
  <pre><code>&lt;form name="CIMtrek_Compliance_Daily_Shipments" enctype="multipart/form-data"&gt;
  &lt;input type="file" id="CIMtrek_comments" name="CIMtrek_comments" value="" /&gt;
      &lt;button id="upload" onclick="uploadCommentFile()"&gt;Upload&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>and this is my ajax call using jquery : </p>
  
  <pre><code>function uploadCommentFile(){
      $("#upload").live("click", function() {
          var file_data = $("#CIMtrek_comments").prop("files")[0];   // Getting the properties of file from file field
          var form_data = new FormData();                  // Creating object of FormData class
          form_data.append("file", file_data)              // Appending parameter named file with properties of file_field to form_data
          //form_data.append("user_id", 123)                 // Adding extra parameters to form_data
          $.ajax({
                      type: 'POST',
                      url: "/CIMtrek_Compliance_Daily_Shipments_FileUpload",
                      dataType: 'script',
                      cache: false,
                      contentType: false,
                      processData: false,
                      data: {
                           uploadFile:  file_data
                         },
                      success: function (msg) {
                          global.getElementById("CIMtrek_uploadedFileName").innerHTML=msg;
                      }
             })
      })
  
  }
  </code></pre>
  
  <p>and this is my spring controller :</p>
  
  <pre><code> @RequestMapping(value = "/CIMtrek_Compliance_Daily_Shipments_FileUpload", method = RequestMethod.POST)
      public String createComments(@RequestParam("uploadFile") CommonsMultipartFile uploadItem,
              HttpServletRequest request) {
          String uploadedFileName="";
          try {
              MultipartFile file = uploadItem;
              String fileName = null;
              InputStream inputStream = null;
              OutputStream outputStream = null;
              if (file.getSize() &gt; 0) {
                  inputStream = file.getInputStream();
  
                  System.out.println("size::" + file.getSize());
                  fileName = request.getRealPath("") + "/WEB-INF/resources/Attachment"+ file.getOriginalFilename();
  
                  System.out.println("path : "+request.getRealPath("") + "/WEB-INF/resources/Attachment");
                  outputStream = new FileOutputStream(fileName);
                  System.out.println("fileName:" + file.getOriginalFilename());
  
                  int readBytes = 0;
                  byte[] buffer = new byte[10000];
                  while ((readBytes = inputStream.read(buffer, 0, 10000)) != -1) {
                      outputStream.write(buffer, 0, readBytes);
                  }
                  outputStream.close();
                  inputStream.close();
              }
              uploadedFileName =file.getOriginalFilename();
          } catch (Exception e) {
              e.printStackTrace();
          }
          return uploadedFileName;
      }
  </code></pre>
  
  <p>but i get the following exception when i click on upload button :</p>
  
  <pre><code>HTTP Status 400 - 
  The request sent by the client was syntactically incorrect.
  </code></pre>
  
  <p>what could be the problem, Please help me to identify.</p>
  
  <p>Best Regards.</p>