Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

POST data truncated between browser and PHP

I'm running into an issue where large data sets sent over POST using AJAX are not making it to the $_POST variable in PHP.

The user uploads an Excel/CSV file through a webform and is parsed via AJAX. This particular example has 775 records with 13 fields/elements each. Adding additional fields being submitted and there are less than 11,000 elements in the dataset. From the research I've done on the subject, 32-bit browsers (i.e. Firefox, Chrome, etc.) should be able to handle 4.29 billion elements, so I don't see the data size as an issue, especially as the response from the file upload contains all the elements.

The issue only rears its head when the entire form is submitted to be validated and entered into the database. The issue is that the console on both Firebug and Chrome Developer Tools shows that the whole data set is submitted: Firebug Output

Doing a var_dump on the $_POST gives this: enter image description here

The php.ini has 'post_max_size' set to 200M. Even 'upload_max_filesize' is set to 100M. This issue occurs in both Firefox 32.0.3 and Chrome 37.0.2062.103 m that I have tested personally and other older versions (including IE 10) that UAT has tested.

The AJAX call is:

new wrapper.ajax('/t1.php', {
    type: 'POST',
    data: data,
    form: $('form[name=oppForm]'),
    success: function (response)
    {
    if (response.result)
    {
        window.location = response.result;
    }
    },
    complete: function ()
    {
    $("#submit").loading('done');
    }
});

The PHP is:

<?php
var_dump($_POST);

Any thoughts?

EDIT

After talking with some other developers, I also checked the output of php://input and found that it DID contain the entire POST data that the browsers were sending, but that the data was not getting translated into $_POST properly. However, it does work properly if I remove 10 keys from the post data, and submit 765 instead of 775.

like image 888
Scott T Rogers Avatar asked Oct 07 '14 16:10

Scott T Rogers


1 Answers

The issue ended up being that 'max_input_vars' in the php.ini file was not set high enough. The value was set to 10,000 and the user was submitting data of near 11k, thus some of it was getting truncated. Changing this value to be greater is what solved the issue.

like image 93
Scott T Rogers Avatar answered Oct 18 '22 17:10

Scott T Rogers