I'm still new to this business. The situation is this: sending an array of strings via JSON, but only 1000 strings arrive on the server. How to fix it?

var data = DataArr; alert(data.length);//тут более 1000 строк if (id == 0) { $.ajax({ type : 'POST', url : 'createFile.php', dataType : 'json', data : { '0' : data }, response : 'text', success : function(data) { alert("Выполнено!"); DownloadFile(data.path, 0); } }); DataArr.length = 0; } 

On the server side I accept:

 global $file; if (!empty($_POST['0'])) { $rand = uniqid(); mkdir(dirname(__FILE__) . "/files/" . $rand); $dataArr = $_POST['0']; echo (count($dataArr));//а тут ровно 1000 строк $file = "/files/" . $rand . "/" . $dataArr[0]; $fp = fopen(dirname(__FILE__) . "/files/" . $rand . "/" . $dataArr[0], "w"); for ($i = 1; $i < count($dataArr); $i++) { fwrite($fp, $dataArr[$i] . "\r\n"); } fclose($fp); $json_path = array('path' => $file); echo json_encode($json_path); } 
  • you send json, but for some reason you read the pure $ _POST - etki
  • there are no problems with reading, everything adequately falls into place, only cuts up to 1000 lines. - Nurk33RUS
  • Does max_input_vars increase anything? and how can cut lines if json is one line? - Alexey Shimansky
  • gives nothing, tried php.ini and .htaccess to edit. Perhaps the value is blocked by hosting? - Nurk33RUS
  • I called technical support, they said that the limit of 1000 is worth it. The question is removed. - Nurk33RUS

1 answer 1

Increase the max_input_vars value in php.ini. By default, PHP clips arrays up to 1000 lines in POST.