Viewed   410 times

I'm trying to send POST data that is 2 million characters big (non-binary string) via ajax (jQuery) and it always comes up as blank on the PHP side. Here is my code:

var string = "<data string that is 2M chars long>";
    cache: false,
    type: 'POST',
    url: 'data.php',
    data: {'data_string': string}

On the PHP side, I get the following error message (when trying to retrieve data from $_POST['data_string']):

Notice: Undefined index: data_string in data.php on line ...

I've checked the post_max_size in php.ini, and it's set at 256M which should be more than enough? I'm stumped and not sure what I'm doing wrong...

EDIT: If I make "string" a small amount of data (e.g. var string = 'test') then $_POST["data_string"] returns test, as expected. So I'm wondering if there's some sort of data limit I'm reaching in Apache2, PHP or the browser itself? I'm using Google Chrome 17.0.963.79

EDIT2: memory_limit = 256M in php.ini

EDIT3: max_input_time = -1 in php.ini

EDIT4: var_dump($_POST) returns Array(0)

EDIT5: running the latest stable version of PHP5 on debian squeeze: PHP 5.3.3-7+squeeze8 with Suhosin-Patch (cli) (built: Feb 10 2012 14:12:26)



You'll have to check the limits parameters on all items between you and the server. Quite hard for proxy servers if any, but at least you can check:


  • LimitRequestBody, around 2Gb by default, maybe greater for 64bits, check error logs for details.


  • post_max_size which is directly related to the POST size
  • upload_max_filesize which may be unrelated, not sure
  • max_input_time, if the POSt takes too long
  • max_input_nesting_level if your data is an array with a lot of sublevels
  • max_execution_time, but quite sure it's not that
  • memory_limit, as you may reach a size exceding the subprocess allowed memory
  • max_input_vars, if your data array has many elements

If you have reached the compiled in limit for Apache your only solution is to avoid direct POSt of such a big chunk of data, you'll have to break it into pieces.

Thursday, September 29, 2022

I think you've got almost everything. The callback function you have under success needs an argument which stands for the results from search.php

     success: function(res) {
             $('#result').html("<br><br><br><br><br><br><br><br><br><br><div class='center'><img src='img/loader.gif' /></div>").hide().fadeIn(2500, function() {
                 $('#result').html(res + "<br /><br /> Finished");

res is everything outputted be search.php. Echo, stuff outside of php tags, etc Anything you'd see if you loaded search.php itself.

I don't know if you wanted 'Finished' to still be there. Take it out if you dont.

Tuesday, October 18, 2022

EDIT (2019) This answer is now pretty redundant but there is another answer with more relevant information.

It rather depends on the web server and web browser:

Internet explorer All versions 2GB-1
Mozilla Firefox All versions 2GB-1
IIS 1-5 2GB-1
IIS 6 4GB-1

Although IIS only support 200KB by default, the metabase needs amending to increase this.

The POST method itself does not have any limit on the size of data.

Thursday, November 24, 2022
  1. post_max_size should be 3G

  2. upload_max_filesize should be 3G

  3. memory_limit depends!!! what you are going to do with the file. If you are going to manipulate the file or do other memory intensive jobs, then you will need to set a high limit. If you don't want to put a maximum limit, you can always set it to -1. This value doesn't have to do much with the size of the file, but rather with the size of the physical memory your script needs to handle the job.

For the first two, it is the maximum file size you expect to be uploaded, suffixed with a short hand byte value. For KB should be K, MB should be M, GB should be G, ...

Wednesday, November 2, 2022

i think your problem may be in ajax code since you are using formData object . try append the message variable with it

$('#submit').on('click', function(){

  var fd = new FormData(this);
  fd.append('message ',$('#message').val());

    url:"<?php echo site_url('home/send_chat');?>",    
    data: fd,  
    cache: false,
    contentType: false,
    processData: false,   
    success: function(data){                 
    error: function(xhr, status, error) {
Saturday, November 12, 2022
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :