Angularjs send http post request, php can’t receive post data from $_POST.

Angularjs send http post request, php can’t receive post data from $_POST.
Below is the request header content type.
“Content-Type”: ‘application/json;charset=utf-8’

PHP only transitions the two request headers by default:
application/x-www-form-urlencoded
text/html;

If you want receive the post data, you can use the code below.

$put=file_get_contents('php://input');
$put=json_decode($put,1);
foreach ($put as $key => $value) {
    $_POST[$key]=$value;   
}

Related posts:

Leave a Reply

Your email address will not be published.