title: Upload an Excel File using Jquery
body: <p>I want to upload an Excel file using Jquery through RestEasy Service which consumes multipart/form-data. Whether I want to use Ajax for File upload or simple Jquery/Javascript is more enough. If I want to use only Ajax means, what kind of content-type do I have to post for upload?</p>
  
  <p>This is my HTML &amp; Jquery Code.</p>
  
  <pre><code>&lt;script type="Javascript"&gt;
      $(document).ready(function () {
          //var filename = document.getElementById("uploadedFile").value;
          var filename = $("#uploadedFile").val();
          //alert(filename);
          jQuery("#Upload").click(function () {
              $.ajax({
                  url: 'service url',
                  type: 'POST',
                  contentType: 'application/json; charset=utf-8',
                  // enctype: 'multipart/form-data',
                  data: {
                      file: filename
                  },
                  cache: false,
                  success: function (data) {
                      alert('success');
                      return false;
                  },
                  error: function (data, status) {
                      alert("failue");
                      alert(status);
                  }
              });
          });
      });
  &lt;/script&gt;
  
  &lt;input type="file"  name="uploadedFile" id="uploadedFile" size="30" &gt;&lt;br&gt;&lt;br&gt;
  &lt;input type="button" id="Upload" name="Upload" value="Upload"  style="width:72px;height:23px;"&gt;
  </code></pre>