Krystian
Krystian

Reputation: 458

Using jQuery to send very long string PHP

I would like to send very long string (about 1 200 000 chars) from my jQuery script to PHP server. I created code:

$.ajax({
    url : 'con.php',
    async : false,
    type : 'POST',
    data : 'require='+parameters
}).done(function(result) {
    console.log(result);
});

where parameters is describing string and in PHP:

if ($_POST['require']){
echo 'ok';
}

When I'm sending normal-size string everything is good, but when I sent my big string I got the error message:

Notice: Undefined index: require

I setup memory_limit in my php.ini to 500M and still get nothing.

I tried to use [suhosin][1] with setting up suhosin.memory_limit greater than 0 with same results as above.

How can I resolve my problem?

Upvotes: 1

Views: 666

Answers (1)

Ozzy
Ozzy

Reputation: 10643

Try having your data sent like this:

data: {
    require: parameters
}

and set your php max post sizes:

post_max_size=20M
upload_max_filesize=20M

Upvotes: 1

Related Questions