title: Posting a form with ajax - "The current request is not a multipart request"
body: <p>I have this simple form:</p>
  
  <pre><code>&lt;form id="myForm" method="POST" action="/project/upload" target="myFrame"
  enctype="multipart/form-data"&gt;
  
  
  Please select a file to upload : &lt;input id="file" type="file" name="file" /&gt;
  &lt;input type="button" onclick="initSubmit()" value="upload" /&gt;
  &lt;/form&gt;             
  &lt;iframe name="myFrame" height=0 width=0&gt;&lt;/iframe&gt;
  </code></pre>
  
  <p>I get the following error: </p>
  
  <pre><code>org.springframework.web.multipart.MultipartException: The current request is not a multipart request
  </code></pre>
  
  <p>here is my javascript:</p>
  
  <pre><code>function submitForm() {
      $("form#myForm").submit();
  }
  
  function initSubmit() {
  
  $('form#myForm').submit(function () {
      $.post('/project/upload', $('form#myForm').serialize(), function (data, textStatus) {
              debugger;
           alert("Yeah!, i can get the call back!");
      });
      return false;
  });
  submitForm();
  </code></pre>
  
  <p>}</p>
  
  <p>here is my controller method:</p>
  
  <pre><code>@RequestMapping(value = "/upload", method = RequestMethod.POST)
  public String handleFormUpload( 
      @RequestParam("file") MultipartFile file,HttpServletResponse response ) throws IOException{
  if (!file.isEmpty()) {
   // handle here
   }
  return imageURL;
  }
  </code></pre>
  
  <p>I'm 100% percent sure the ajax call is invalid for my controller </p>
  
  <p>p.s I'm doing this for the callback function. i need to receive the imageURL back in the client and apparently forms callbacks are complicated.</p>
  
  <p>p.s #2 - submitting the form regularly without the js addition, works, but then i cant get the callback context</p>