title: How to pass file object through ajax sumbit with spring mvc controller
body: <p>I am trying to pass the file object through jquery ajax submit.
  <br/><strong>JSP code</strong></p>
  
  <pre><code>&lt;div id="import-file"&gt;
          &lt;input type="file" id="file"/&gt;
          &lt;table&gt;
          &lt;tr&gt;&lt;td&gt;&lt;input type="radio" name="type" value="csv"&gt;&lt;/td&gt;&lt;td&gt;CSV File&lt;/td&gt;&lt;/tr&gt;
          &lt;tr&gt;&lt;td&gt;&lt;input type="radio" name="type" value="excel"&gt;&lt;/td&gt;&lt;td&gt;Excel spread sheet&lt;/td&gt;&lt;/tr&gt;
          &lt;tr&gt;&lt;td&gt;&lt;input type="radio" name="type" value="tab"&gt;&lt;/td&gt;&lt;td&gt;Tab delimited&lt;/td&gt;&lt;/tr&gt;
          &lt;/table&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>Java script code</strong>              </p>
  
  <pre><code>        var type = $($('input:radio:checked')[0]).val();
          var file = $("#file")[0].files[0];
          alert($("#file")[0].files[0].name);
          $.ajax({
              data :{
                  "file" : file,
                  "type" : type
              },
              type: "POST",
              url: "fileupload.htm",
              success: function(data){
                  alert(data);
              },
              error:function(err){
                  alert(err);
              }
          });
  </code></pre>
  
  <p>finally here is my spring controller code:</p>
  
  <pre><code>@RequestMapping(value="fileupload.htm",method=RequestMethod.POST )
      public @ResponseBody String uploadFile(@RequestParam String type, @RequestParam("file") MultipartFile file){
          logger.info("file type : "+type + "file is "+file.toString());
          return "SUCCESS";
      }
  </code></pre>
  
  <p>Am getting NS_NOINTERFACE: Component does not have requested interface [nsIDOMBlob.slice] error in my firebug console.</p>