File_Get_Contents('Php://Input') Always Returns an Empty String

file_get_contents('php://input') Returns empty for one user, but works fine for others

Alright so I figured out the issue, incase anyone runs into this issue in the future.
I went to spend more time trying to Bugfix this issue today and the user was getting a new error, this time an entire error page response from my hosting service, outside of my control. This error said:

"The page you are trying to access is restricted due to a security rule. If you believe that this security rule is affecting the normal operation of your website, contact your hosting provider with detailed instructions how to recreate this error."

I use Siteground to host my website, so I contacted them to attempt to resolve this issue. Long story short they have a specific security rule on their backend that has issues with Bitdefender, and it was now blocking him. The support agent had to unblock his IP and he uninstalled Bitdefender and now everything is working fine. Bitdefender was blocking his POST requests for some reason. I don't really understand why and the support agent that I talked to couldn't tell me why but just try to uninstall/disable your Bitdefender, and if you're getting blocked with a security rule contact your hosting provider and see if they've blocked the IP.

file_get_contents('php://input') returns empty when sending thru url parameter

This is described in php://input

php://input

php://input is a read-only stream that allows you to read raw data from the request body. In the case of POST requests, it is preferable to use php://input instead of $HTTP_RAW_POST_DATA as it does not depend on special php.ini directives.

The important part is "POST reqest".

This means, when you say http://www.example.com/tests/testtest.php?name=what, you send a GET request and not a POST request. Therefore, there is no request body, and you cannot read anything through php://input.


To read form input passed as URL parameters, you may use the global $_GET variable.

When you use a POST request, you usually use the global $_POST array, instead of reading the request body manually through php://input.

You may also consider $_REQUEST, if you don't care if it is a POST or GET request. Although, be aware of What's wrong with using $_REQUEST[]?

file_get_contents('php://input') not working. Empty - NULL

I fix it, don't know how, but i think the solution was:
Delete my htaccess completely, no redirections (http to https).
Dont test with reqbin, test it with php pure code, or PostMan.

file_get_contents(php://input) is empty if the POST body is above ~16 000 characters

The solution was to create an empty folder named tmp in the public root.
In most cases it most likely would be created automatically (if needed at all), however this hosting company's configuration is flawed, I believe.

file_get_contents('php://input') keeps returning empty

HTTP POST data is usually populated in $_POST, php://input will usually contain PUT data.

file_get_contents returns empty string

I fixed this issue on my server (running PHP 5.3.3 on Fedora 14) by removing the --with-curlwrapper from the PHP configuration and rebuilding it.



Related Topics



Leave a reply



Submit