title: File Upload Without Using Any Asp Controls
body: <p>I'm trying to upload an image without using any of the asp controls. So far I've been trying:</p>
  
  <pre><code>        &lt;form id="form1" data-ajax="false" method="post" runat="server" enctype="multipart/form-data"&gt;
              &lt;input type="file" id="uploadFile" name="uploadFile" runat="server"/&gt;
              &lt;input type="submit" class="btn-login" data-corners="true" value="Yükle" onclick="UploadPhoto()" /&gt;
          &lt;/form&gt;
  </code></pre>
  
  <p>in my .aspx page and in UploadPhoto() method in JQuery:</p>
  
  <pre><code>function UploadPhoto() {
              $.ajax({
                  type: "POST",
                  url: "IncidentChange.aspx/UploadPhoto",
                  contentType: "application/json; charset=utf-8",
                  success: function (msg) {
                  },
                  error: function () {
                  }
              });
          }
  </code></pre>
  
  <p>I am posting to C# code behind. However, I could not reach the uploaded item from codebehind.</p>
  
  <pre><code>        [WebMethod]
          public static string UploadPhoto()
          {
              try
              {
                  byte[] fileData = null;
                  using (var binaryReader = new BinaryReader(HttpContext.Current.Request.Files[0].InputStream))
                  {
                      fileData = binaryReader.ReadBytes(HttpContext.Current.Request.Files[0].ContentLength);
                  }
  
              }
              catch (Exception ex)
              {
              }
              return null;
          }
  </code></pre>
  
  <p>However Request.Files appears to be a null array. Since the method is static ([WebMethod]) I cannot reach the input control within the method to get the posted file. How can I overcome this issue? Thank you.</p>