user4287915
user4287915

Reputation: 366

php post empty if textarea over 1 million characters

I have a textarea, it works fine if there are less than 1 million characters. As soon as something is posted over 1 million characters that field is missing in $_POST (all other fields are posted).

What could be causing this? When searching all I have seen mentioned is there are no character limits only post size limit and memory limit. No errors are being displayed and these are set well over the 2Mb text size.

Upvotes: 0

Views: 395

Answers (2)

user4287915
user4287915

Reputation: 366

Managed to solve the issue, it was suhosin limiting the characters. I needed to set the following:

suhosin.request.max_value_length = 100000000
suhosin.post.max_value_length = 100000000

Upvotes: 1

hmd
hmd

Reputation: 970

Did you try increasing post_max_size in php.ini file?

Moreover, you can also use some other way to post your data i.e use:

//execute an async method
function curl_request_async($url, $params, $type='GET'){

    $post_params = array();
    foreach ($params as $key => &$val) {
        if (is_array($val)) $val = implode(',', $val);
        $post_params[] = $key.'='.urlencode($val);
    }
    $post_string = implode('&', $post_params);

    $parts=parse_url($url);
    $fp = fsockopen($parts['host'],
        (isset($parts['scheme']) && $parts['scheme'] == 'https')? 443 : 80,
        $errno, $errstr, 999999999);

    $out = "$type ".$parts['path'] . (isset($parts['query']) ? '?'.$parts['query'] : '') ." HTTP/1.1\r\n";
    $out.= "Host: ".$parts['host']."\r\n";
    $out.= "Content-Type: application/x-www-form-urlencoded\r\n";
    $out.= "Content-Length: ".strlen($post_string)."\r\n";
    $out.= "Connection: Close\r\n\r\n";
    // Data goes in the request body for a POST request
    if ('POST' == $type && isset($post_string)) $out.= $post_string;

    fwrite($fp, $out);
    fclose($fp);
}

You can call this function like:

$url = "somefile.php";
$data['mydata'] = "some data some data some data";
curl_request_async( $url, $data, 'POST' );

Note:

Do not use any type of Session based authentication in file "somefile.php". And you can access post data like $_POST['mydata']. You can also call this function in by GET. Don't know what you are actually looking for.

Upvotes: 0

Related Questions