3

I'm trying to post an image to a php page as a base64 encoded string and it works fine while the image file is smaller than about 800KB but if the file is bigger the $_POST var is missing the image value.

post data looks like

[email protected]&image={image base64 encoded}&name=Bob

if I inspect the $_POST var using var_dump($_POST) and the file is smaller than 800KB it prints the following:

array(3) {
    ["email"]=>string(11) "[email protected]"
    ["image"]=>string(936816) "{image base64 encoded}"
    ["name"]=>string(3) "Bob"
}

...if the file is bigger than about 800KB it prints:

array(2) {
    ["email"]=>string(11) "[email protected]"
    ["name"]=>string(3) "Bob"
}

But in both cases the data is definitely posted to the php script (I inspected the webrequests through fiddler).

post_max_size is set to 8MB and memory_limit to 128MB so this should not be a problem.

Thanks in advance for any suggestions!

3
  • What's your form's tag code?
    – SaidbakR
    Sep 2, 2013 at 21:57
  • I'm not using a form i'm posting the data through a WebRequest from c# but as said in my post, if i inspect the request using fiddler it's correct, so this should not cause the problem!
    – Malte G
    Sep 2, 2013 at 22:07
  • possible duplicate of PHP some $_POST values missing but are present in php://input
    – Phil
    Sep 2, 2013 at 22:43

1 Answer 1

0

I'm thinking that it has something to do with server limitations... although POST data has no limits, sometimes (most of the time) there are some outgoing/incoming server/script limitation. Could you try to gzip binary content ant try to push it through POST?

$encoded = base64_encode(gzcompress(serialize($original)));

$original = unserialize(gzuncompress(base64_decode($_POST['encoded'])));

Idea Source

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.