title: The current request is not a multipart request
body: <p>On uploading my file by ajax I am facing Exeption</p>
  
  <blockquote>
    <p>org.springframework.web.multipart.MultipartException: The current request is not a multipart request</p>
  </blockquote>
  
  <p>I google this and find many solution,applied all of them no one resolved my problem-</p>
  
  <p>Below is my <code>html-file</code></p>
  
  <pre><code>&lt;form id="upload-file-form"&gt;
     &lt;label for="upload-file-input"&gt;Upload your file:&lt;/label&gt;
     &lt;input id="upload-file-input" type="file" name="uploadfile" accept="*" enctype="multipart/form-data" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Script for ajax-</p>
  
  <pre><code>$.ajax({
           url: "/util/uploadFile",
           type: "POST",
           data: {'uploadfile':new FormData($("#upload-file-form")[0])},
           enctype: 'multipart/form-data',
           processData: false,
           contentType: false,
           cache: false,
           success: function () {},
           error: function () {}
           });
  </code></pre>
  
  <p>And this is my Spring boot Controller("/util")-</p>
  
  <pre><code>@RequestMapping(value = "/uploadFile", method = RequestMethod.POST)
      @ResponseBody
      public String uploadFile(@RequestParam("uploadfile") MultipartFile uploadfile) {
          System.out.println("----------------");
          System.out.println("----------------" + uploadfile);
          return "success";
      }
  
  
      @Bean
      public MultipartConfigElement multipartConfigElement() {
          return new MultipartConfigElement("");
      }
  
      @Bean
      public MultipartResolver multipartResolver() {
          org.springframework.web.multipart.commons.CommonsMultipartResolver multipartResolver = new org.springframework.web.multipart.commons.CommonsMultipartResolver();
          multipartResolver.setMaxUploadSize(4000000);
          return multipartResolver;
      }
  </code></pre>