First introduce:
$_post: An array of variables passed by the HTTP POST method. is an automatic global variable.
$GLOBALS [' Http_raw_post_data ']: always produces $HTTP _raw_post_data variable contains the original POST data. This variable is only generated when it encounters data that does not recognize the MIME type. $HTTP _raw_post_data is not available for enctype= ' multipart/form-data ' form data.
That is to say, basically $globals[' http_raw_post_data ' is the same as $_post.
But if the POST data is not recognized by PHP, you can use $GLOBALS [' Http_raw_post_data '] to receive it, such as text/xml or soap, etc.
Php://input allows the raw data to be read from the POST. Compared to $HTTP _raw_post_data, it brings less pressure to memory and does not require any special php.ini settings. Php://input cannot be used for enctype= "Multipart/form-data".
Problem:
Originally, I was thinking, what if I pass two binary pictures?
Later I was uploaded separately for each picture.
Scatter---------------------------------------------------------------------------------------------------------------------dividing line ------------------
$xmlstr = $GLOBALS [Http_raw_post_data]; Can be used to receive binary images,
if (empty ($xmlstr)) $xmlstr = file_get_contents (' php://input '); //This method is the same as above, and can be used to receive binary images
$jpg = $xmlstr;//get post binary raw data
$filename = "Test.jpg";
$file = fopen (".. /data/apps/". $filename," w ");//Open file ready to write
if (! $file) {
$res [' Code ']=0;
$res [' msg ']= ' upload image failed ';
exit;
}
fwrite ($file, $jpg);//write
fclose ($file);//Close