title: Sending file from JQuery Ajax to C# Webmethod
body: <p>I want to send data from aspx page to .cs Webmethod using jQuery Ajax. my html code is as shown below</p>
  
  <pre><code>            &lt;tr&gt;
                  &lt;td&gt;
                      &lt;input type="text" id="txtName"&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;
                      &lt;form action="" id="AttachmentForm1" enctype="multipart/form-data"&gt;
                          &lt;input type="file" name="UploadFile1" id="txtUploadFile1" class="btn btn-sm" /&gt;
                      &lt;/form&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
  </code></pre>
  
  <p>And my javascript code as below</p>
  
  <pre><code> function saveData() {
  
      var file = $("#txtUploadFile1")[0].files[0];
  
      $.ajax({
          url: 'CCA_Form.aspx/SaveData',
          type: 'POST',
          dataType: 'json',
          contentType: 'application/json; charset=utf-8',
          data: JSON.stringify({  Name: txtName, fileData: file }),
          success: function () {
              alert("Data Added Successfully");
          },
          error: function () {
              alert("Error while inserting data");
          }
      });}
  </code></pre>
  
  <p>And my c# code as below</p>
  
  <pre><code>    [WebMethod]
      [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
      public static bool SaveData(string Name, string[] fileData)
      {
          //Breakpoint
          return true;
      }
  </code></pre>
  
  <p>how can i get uploaded file in Webmethod in c#?</p>
  
  <p>Thanks in advance.</p>