John Smith
John Smith

Reputation: 4353

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

I've got an application that sends relatively large POST requests to an Apache shared hosting.

On the server, there's a .php file with

file_get_contents("php://input")

that's supposed to read the POST raw body. It works as long as the POST body is less than ~16000 characters in length. If there are more, the above piece of code returns an empty string.

I'd like to have the entire body returned, regardless of its length.

Upvotes: 2

Views: 1125

Answers (3)

John Smith
John Smith

Reputation: 4353

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.

Upvotes: 2

Thrallix
Thrallix

Reputation: 731

Try adding this all the way on top of your script:

<?php

error_reporting(E_ALL);
ini_set('display_errors', 1);

You are most likely getting an error that you cannot see due to errors being disabled.

You can also try removing --with-curlwrapper from the PHP configuration and rebuilding it. file_get_contents returns empty string

Upvotes: 1

Flunch
Flunch

Reputation: 21

The problme might be with the web server. You may try to up the body limit on your web server software. For example in Apache :

LimitRequestBody 

in Nginx :

client_max_body_size

Upvotes: 2

Related Questions