1

Im receiving JSON data using PHP.
I'm using file_get_contents("php://input") but it doesn't work.
It returns String(0);.
This is my code:

echo $content = file_get_contents("php://input");
//Attempt to decode the incoming RAW post data from JSON.
$decodedarray = json_decode($content, true);

I have looked into my php.ini file and allow_url_fopen returns 1.
I don't know what I'm doing wrong.

  • Where did you find that? Or better why do you want to do it in this way? And explain `receiving JSON`? How? http://stackoverflow.com/questions/8893574/php-php-input-vs-post http://stackoverflow.com/questions/2731297/file-get-contentsphp-input-or-http-raw-post-data-which-one-is-better-to – JustOnUnderMillions Mar 10 '17 at 14:05
  • Im receiving a Json request and i like to show that data. –  Mar 10 '17 at 14:46
  • mmmh you say that you are getting `String(0)` thing you have to find the solution for the bug in the links above, it seems that it is not send in the right way. Also check http://php.net/manual/en/wrappers.php.php there `php://input is not available with enctype="multipart/form-data"` – JustOnUnderMillions Mar 10 '17 at 14:56
  • Im using JSON as enctype, so i don't know what is wrong –  Mar 10 '17 at 14:59
  • Currently i thing it is an issue with the data that is send. Is `$_POST` empty at this point? – JustOnUnderMillions Mar 10 '17 at 15:08

0 Answers0