Php input stream: // analysis of input, input stream input
In php, you can use php: // input to obtain the content after taking a camera photo and uploading it. So I learned about php: // input.
From the official website information, php: // input is a read-only information stream. When the request method is post and enctype is not equal to "multipart/form-data", you can use php: // input to obtain the data of the original request.
Let's look at a simple example.
The client is a form, which is very simple.
Copy codeThe Code is as follows:
<Form action = "" method = "POST">
Name: <input type = "text" name = "name" value = "tom"/> <br/>
Age: <input type = "text" name = "age" value = "22"/> <br/>
<Input type = "submit" value = "Submit"/>
</Form>
Submit the form to the server. The server uses file_get_contents to obtain the php: // input content.
Copy codeThe Code is as follows:
$ Content = file_get_contents ("php: // input ");
Echo $ content; // output name = tom & age = 22
The $ HTTP_RAW_POST_DATA variable is repeatedly mentioned in the php: // input description on the official website. The variable actually has the same content as file_get_contents (php: // input. To enable this variable, You need to modify the configuration file, find the always_populate_raw_post_data option, set it to On, and then restart the web server. Php: // input does not need to modify the php configuration file.
Php: // input can be used in project applications, such as camera photos, upload and save. After taking a photo from the client and sending the image to the server, the server can use file_getcontents ('php: // input') to get the image stream and save the image stream to a file, this file is an image.
Which of the following statements about file_get_contents ("php: // input") in php?
Read the php input stream to a string, which is different from $ _ post and $ _ GET. For details, see manual.
Save php: // input
$ Content = file_get_contents ("php: // input ");
File_put_contents('a.txt ', $ content );