title: How to upload file using ajax file upload and spring mvc?
body: <p>I have a jsp file in which i am uploading a file using ajax file upload method. For backend handling of file i made a contoller in spring. But i could not find that how can i handle file in spring 2.5 in this condition ?
  My Code is - </p>
  
  <p><strong>JSP FILE</strong></p>
  
  <pre><code>&lt;input type="file" name="file" /&gt;
  &lt;script type="text/javascript"&gt;
          function saveMedia() {
              var formData = new FormData();
              formData.append('file', $('input[type=file]')[0].files[0]);
              console.log("form data " + formData);
              $.ajax({
                  url : 'ajaxSaveMedia.do',
                  data : formData,
                  processData : false,
                  contentType : false,
                  type : 'POST',
                  success : function(data) {
                      alert(data);
                  },
                  error : function(err) {
                      alert(err);
                  }
              });
          }
      &lt;/script&gt;
  </code></pre>