I receive POST request on my api.php script. The content red using this code:
$fp = fopen('php://stdin', 'r');
$all = "";
while($line = fgets($fp, 4096)) {
$all .= $line;
}
echo $all;
looks like this:
------------V2ymHFg03ehbqgZCaKO6jy
Content-Disposition: form-data; name="intro"
O
------------V2ymHFg03ehbqgZCaKO6jy
Content-Disposition: form-data; name="title"
T
------------V2ymHFg03ehbqgZCaKO6jy
Content-Disposition: form-data; name="apiKey"
98d32fdsa
------------V2ymHFg03ehbqgZCaKO6jy
Content-Disposition: form-data; name="method"
/media/add
------------V2ymHFg03ehbqgZCaKO6jy
Content-Disposition: form-data; name="upload_field"; filename="original_filename.png"
Content-Type: image/png
------------V2ymHFg03ehbqgZCaKO6jy--
As you can see I get 4 parameters called intro, title, apiKey and method, and one file called original_filename.png with size of 1460 bytes.
Unfortunately, my $_POST array is empty. What is weird when orginal_filename.png is less than 1450 bytes $_POST contains all parameters, and stdin is empty.
I would like to be able to read these fields like normal human PHP being from $_POST.
What to do in order to read this POST request parameters properly from $_POST?