php gets the implementation method of json data in post

  • 2020-05-07 19:22:24
  • OfStack

I suddenly thought that I had contacted flash before and passed the picture 2 to php, so I used $GLOBALS['HTTP_RAW_POST_DATA'] to get it.
Therefore, PHP only recognizes the application/ x-www.form-urlencoded standard data type by default. Therefore, the type such as text/xml or soap or application/ octet-stream cannot be resolved. So keep the prototype and give it to $GLOBALS['HTTP_RAW_POST_DATA'] to receive.

The php HTTP_RAW_POST_DATA
How to obtain POST data by submitting an xml document to php server using Content-Type =text/xml type.
The RAW / uninterpreted HTTP POST information can be accessed with: $GLOBALS['HTTP_RAW_POST_DATA'] This is useful in cases where the post Content-Type is not something PHP understands (such as text/xml).
Since PHP only recognizes application/ x-www.form-urlencoded standard data types by default, the contents of a type such as text/xml cannot be resolved into a $_POST array, so keep the prototype and send it to $GLOBALS['HTTP_RAW_POST_DATA'] for receiving.
There is another item php://input can also achieve this function
php://input allows reading of POST raw data. It puts less pressure on memory than $HTTP_RAW_POST_DATA and doesn't require any special php.ini Settings. php://input cannot be used with enctype="multipart/ form-data ".

application

a.htm
 
<form action="post.php" method="post"> 
<input type="text" name="user"> 
<input type="password" name="password"> 
<input type="submit"> 
</form> 

post.php
 
<? echo file_get_contents("php://input");?> 

Related articles: