Put method support

Source: Internet
Author: User

 
Put method support
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

This wowould normally mean that the remote client wowould like to save the content that follows as:/path/filename.html in your web tree. it is obviusly not a good idea for Apache or PHP to automatically let everybody overwrite any files in your web tree. so, to handle such a request you have to first tell your web server that you want a certain PHP script to handle the request. in Apache you do this with the script directive. it can be placed almost anywhere in your Apache configuration file. A common place is inside a <directory> block or perhaps inside a <virtualhost> block. a line like this wocould do the trick:

Script put/put. php

Code
Example # 1 saving http put files

<? 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);
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.