I fight the second day over the following task: there is a database of addresses such as "region", "city", "street", "house", etc. it is necessary to make a mechanism for adding comments to which the list of addresses will be attached, and any level can be attached to a comment, for example:

  1. "do not assign connection on Saturday", associated with the address "Moscow region, g.Korolyov"
  2. "do not assign to sunday" associated with addresses
    "Moscow region, Korolyov, pr. Cosmonauts d5"
    "Moscow region, Korolyov, etc. Cosmonauts d6"
    "Moscow region, Korolyov, etc. Cosmonauts d7"
    "Moscow region, Korolev, Kosmonavtov Avenue, d8"

Accordingly, when sending a comment with a bunch of attached addresses, I have a huge $_POST , which is simply chopped.
I tried to push through $_COOKIE - the result is the same.

I consider as an option the separation of requests for pieces - one per address and the transfer of such Ajax ...
Is this the only option or can it be made more beautiful?

UP: I apologize, misled, the Apache gives an error 414, did not immediately notice it in the logs at the end of the request.

post_max_size 64M
upload_max_filesize 32M
memory_limit 128M ...
And the size of the incoming data is always different! What kind of nonsense is this? Maybe it's in Phalcon `, which is installed?

  • one
    How large? Dimensions. You can try to optimize, replacing, where possible, the list of the range, but this treatment of symptoms. Is it chopped - does it exceed the maximum request size? Then it can be increased. - DanielOlivo
  • Maybe you should understand why the "huge $ _POST" is "being cut" at you? And accordingly reconfigure the server so that it doesn’t crash. - Yaant September
  • Depending on the situation. I think that for real work it is necessary to provide ~ 16K characters. - Afftobus
  • Yaant, twisted PHP configs, directives like post_max_size, upload_max_filesize, max_input_vars - no effect. If the browser cuts - I will not understand, because it is a solution for a particular machine and this way you can not go. - Afftobus
  • @Afftobus, see also the web server configs (nginx, apache or another). - DanielOlivo

2 answers 2

The problem is solved through the php.ini properties:

post_max_size - Total size of POST request by default 8Mb

upload_max_filesize - file size that can be uploaded to the server through POST .

It is very important that the values ​​be:

memory_limit > post_max_size > upload_max_filesize

Also, we don’t forget that the script would have enough time to “chew on” the data max_execution_time

http://php.net/manual/en/info.configuration.php

UPD

1) If you believe these two links, it looks like the data comes through GET. Try looking at the apache access.log URL for requests.

https://stackoverflow.com/questions/2891574/how-do-i-resolve-a-http-414-request-uri-too-long-error

https://docs.phalconphp.com/en/latest/reference/apache.html

2) You can try to get the request body directly through:

 $data = file_get_contents('php://input'); parse_str($data, $result) var_dump($result); 

and see if it's all come.

3) Well, apache also knows how to "trim" POST requests, see:

http://httpd.apache.org/docs/2.0/mod/core.html#limitrequestbody

    I had a similar problem but in another task. It was necessary to synchronize the database tables. In the course of the bill did so. An array of data was divided into pieces and sent in a loop. Here is a sample code.

     $recordChunks = array_chunk($rd[0]['RECORDS'], 7000); foreach ($recordChunks as $chunk) { $rd[0]['RECORDS'] = $chunk; $request = array( 'TOKEN' => $this->getContainer()->getParameter('cdb_token'), 'DATA' => json_encode(array( "DB_VERSION" => $dbVersion, "DATA" => $rd, )), ); $size += strlen($request['DATA']); //отправка данных на ЦБД $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $this->getContainer()->getParameter('https_cdb_from')); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); curl_setopt($ch, CURLOPT_POSTFIELDS, $request); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0); curl_setopt($ch, CURLOPT_TIMEOUT, 0); curl_setopt($ch, CURLOPT_SSLVERSION, 3); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_CAINFO, $this->getContainer()->get('kernel')->getRootDir() . '/адрес.pem'); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); // получить json ответ $response = curl_exec($ch); curl_close($ch); $data = json_decode($response); if (($data->STATUS != 1) || (is_null($data))) { var_dump($table, count($chunk),$rd); $this->em->getFilters()->enable('softdeleteable'); throw new \Exception('Ошибка на ЦБД'); } unset($request); } unset($rd); 
    • I can not use this method, because JSON string form JavaScript `th, respectively, to process it PHP, I need to push it to another page, and the problem is in sticking. - Afftobus