title: What happens when I use HTTP PUT method to upload a local file to server?
body: <p>In my current project, my client application first talk with the server and the server returned an upload url for me to upload a file, the url looks like this:</p>
  
  <p><a href="http://www.example.com/folder/filename.cab" rel="nofollow">http://www.example.com/folder/filename.cab</a></p>
  
  <p>Then I want to use HTTP PUT method to upload the local "c:\temp\result.cab" to the above loacation.
  How could I do this? <strong>And could anyone give me a detailed description about the whole uploading mechanism?</strong> </p>
  
  <p>When I use a ASP.NET upload control, I just click the browse button to locate my file and click submit, and on the server side, I just call the <code>SaveAs()</code> method of the upload control. Here is some code:</p>
  
  <pre><code>protected void UploadButton_Click(object sender, EventArgs e)
  {
      if(FileUploadControl.HasFile)
      {
          try
          {
              string filename = Path.GetFileName(FileUploadControl.FileName);
              FileUploadControl.SaveAs(Server.MapPath("~/") + filename);
              StatusLabel.Text = "Upload status: File uploaded!";
          }
          catch (Exception ex)
          {
              StatusLabel.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message;
          }
      }
  }
  </code></pre>
  
  <p>Some questions are:</p>
  
  <ul>
  <li><p>Who is responsible for reading the file and sending it?</p></li>
  <li><p>What happens when I call <code>FileUploadControl.SaveAs()</code> method? Does the server pull the file from client, or the client push the file to the server?</p></li>
  <li><p>I know HTTP is text based, but my result.cab is not text, so is it Base64 encoded before being sent?</p></li>
  </ul>
  
  <p>Many thanks.</p>
  
  <p><strong>Update:</strong></p>
  
  <p>How does HTTP PUT method work? Is it a client side push, or a server side pull? Or interaction of both like some kind of handshake?</p>