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”.

In addition to you post for the people who don’t know or ask why:
php://input does not work with multipart/form-data because of the way file uploads are streamed directly to disk