1

I have some issue with ajax POST method. I spent two days looking for what could be the problem. I tried to send large string to my PHP server. But the server didn't receive the POST data. I made a little test script to reproduce the bug.

Here is my script who sends a large string to my server with POST method.

var click = function () 
{
  //base_string (1 024 octets)
  var base_string = "aaaaaaaa ... aaaa";
  var big_string = "";
for (i = 0; i < parseInt($("#size").val());i++)
{
   big_string += base_string;
}
  $.ajax({
        xhr: function() {
            var xhr = new window.XMLHttpRequest();
            xhr.upload.addEventListener("progress", function(evt) {
                if (evt.lengthComputable) {
                    var percentComplete = evt.loaded / evt.total;
                    percentComplete = parseInt(percentComplete * 100);
                    console.log(percentComplete + "%");
                }
            }, false);
            return xhr;
        },
        url: "test.php",
        type: "POST",
        data: {
            data: big_string,
            normal : "LOL"
        },
        dataType: "text",
        success: function(_result) {
            console.log("result\n" + _result);
        }
    });
}

And here is my PHP script to see if PHP see my POST data.

<?php 
foreach ($_POST as $key => $value)
{
 echo "{$key} = {$value}\r\n";
}
?>

When I try to send my 1ko string more than 978 times, the server don't receive my POST variable. But see the "normal: 'LOL'" variable.

So I also checked my PHP.ini and here's its configuration :

max_input_vars = 10000
post_max_size = 64M

suhosin.memory_limit=256M
suhosin.log.syslog=511
suhosin.executor.include.max_traversal=5
suhosin.post.max_vars=10000
suhosin.request.max_vars=5000
suhosin.request.max_varname_length=80
suhosin.request.max_totalname_length=300
suhosin.cookie.max_name_length=80
suhosin.post.max_array_index_length=80
suhosin.post.max_name_length=80
suhosin.get.max_array_index_length=80
suhosin.get.max_name_length=80

Do you have any idea on how to fix it ?

Nogigi
  • 11
  • 2
  • 1
    In your browser tools, or using Fiddler, can you verify the data that is being POSTed contains the string? Example using Fiddler: http://stackoverflow.com/a/6939748/11047 – Adrian J. Moreno Jan 19 '17 at 17:04
  • Yes i have tried it .The big string is POSTed but the PHP script didn't received it . Fiddler screenshot : http://imgur.com/a/jqIs9 – Nogigi Jan 20 '17 at 16:54

0 Answers0