Possible Duplicate:
Get raw post data
Reading from php://input
works, except when the request body is in multipart/form-data
format, in which case nothing is read.
I've heard that php://input
can only be read from once, which is what I suspect may be causing this (i.e. PHP may be reading from php://input
when it sees multipart/form-data
before I can get my hands on it). However, in testing I've found that I am able to read from the stream multiple times without issue.
Is there a way to get the request body no matter what format?
Here's what I've got so far:
$body = '';
$handle = fopen('php://input', 'r');
while(!feof($handle)) {
$body .= fread($handle, 1024);
}