Reading raw POST data in PHP

Posted in php | Posted on 12-09-2008

A quick tip for reading raw http POST data in PHP. For example if we have a xml posted to a page, we can read the raw data with the following code.

1
$xml = file_get_contents('php://input');

We could use $HTTP_RAW_POST_DATA instead, but many times it does not work due to some php.ini settings. Note that ‘php://input’ does not work with enctype=”multipart/form-data”.



Comments:

Write a Comment