Questions And Answers

More Tutorials

PHP Uploading files with HTTP PUT

PHP provides support for the HTTP PUT method used by some clients to store files on a server. PUT requests are much simpler than a file upload using POST requests and they look something like this:

PUT /path/filename.html HTTP/1.1

Into your PHP code you would then do something like this:

 /* PUT data comes in on the stdin stream */
  $putdata = fopen("php://input", "r");
 /* Open a file for writing */
  $fp = fopen("putfile.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 */


In this page (written and validated by ) you learned about PHP Uploading files with HTTP PUT . What's Next? If you are interested in completing PHP tutorial, your next topic will be learning about: PHP Type Juggling.

Incorrect info or code snippet? We take very seriously the accuracy of the information provided on our website. We also make sure to test all snippets and examples provided for each section. If you find any incorrect information, please send us an email about the issue:

Share On:

Mockstacks was launched to help beginners learn programming languages; the site is optimized with no Ads as, Ads might slow down the performance. We also don't track any personal information; we also don't collect any kind of data unless the user provided us a corrected information. Almost all examples have been tested. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. By using, you agree to have read and accepted our terms of use, cookies and privacy policy.