title: Upload files asynchronously (AJAX) with HTTP/1.1 PUT method, why not?
body: <p>Uploading files via PUT method, even binary or text, via a "normal web browser" is possible.
  Why many people are just saying, that is not possible ?</p>
  
  <p>Sample code with jQuery and PHP.</p>
  
  <pre><code>$(document).ready(function() {
      $("#uploadbutton").click(function() {
          var filename = $("#file").val();
          $.ajax({ 
          type: "PUT",
          url: "addFile.do",
             enctype: 'multipart/form-data',
             data: {file: filename},
            success: function(){
                 alert( "Data Uploaded: ");
              }
          });     
      });
  });
  </code></pre>
  
  <p>On the server side just read the STDIN stream like</p>
  
  <pre><code>&lt;?php
  /* PUT data comes in on the stdin stream */
  $putdata = fopen("php://input", "r");
  
  /* Open a file for writing */
  $fp = fopen("myputfile.ext", "w");
  
  /* Read the data 1 KB at a time
     and write to the file */
  while ($data = fread($putdata, 1024))
    fwrite($fp, $data);
  
  /* Close the streams */
  fclose($fp);
  fclose($putdata);
  ?&gt;
  </code></pre>