Home  >  Article  >  Backend Development  >  PHP input stream php://input Example of sending image stream to server

PHP input stream php://input Example of sending image stream to server

WBOY
WBOYOriginal
2016-07-25 08:55:11997browse
  1. name:
  2. age:
Copy the code

Submit the form to the server, and the server uses file_get_contents to get the php://input content:

  1. $content = file_get_contents("php://input");
  2. echo $content; //Output name=tom&age=22
Copy code

Instructions on php://input from the official website , the variable $HTTP_RAW_POST_DATA is repeatedly mentioned. This variable is actually the same as the content of file_get_contents(php://input). If you want 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.

Using php://input does not require modifying the php configuration file. In project applications, such as taking pictures with the camera, uploading and saving, you can use php://input. After the client takes a photo, it sends the image stream to the server. The server uses file_get_getcontents('php://input') to get the image stream, and then saves the image stream to a file. This file is the image.



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn