title: Upload a file by posting a file in jquery ajax to an asmx
body: <p>I am trying to upload a file through a web service (ASMX)</p>
  
  <p>I wrote the web service as following </p>
  
  <pre><code>[WebMethod]
  public string UploadProducts(string Title, Stream documentStream)
  </code></pre>
  
  <p>I wrote a script in the client side as following</p>
  
  <pre><code>        var data = new FormData(),
          file = $("#fileUpload")[0].files[0]; // an input of type file
          if (file != null) {
              data.append("Title", "demotitle");
              data.append("documentStream", files[0]);
              $.ajax(
              {
                  url: "FileManager.asmx/UploadFile",
                  dataType: "json",
                  type: "POST",
                  data: data,
                  cache: false,
                  contentType: false,
                  processData: false,
                  success: function () {alert('done') },
                  error: function () { alert('error'); }
              });
  </code></pre>
  
  <p>This seems to be not working. Would be great if somebody can guide me where I am doing it wrong. Thanks in advance :)</p>