I'm getting crazy understanding which is the problem.
I need to send some data to the php server, so that the PHP controller can save them in a text file.
This is the javascript code in the view:
$.ajax({
dataType: 'json',
url: '<?php echo site_url("/Controller/save_file") ?>/'+filename_json,
cache: false,
data: reportData,
type: "POST",
success: function (data, status, xhr)
{
console.log(data);
if(data[0].status == 'success') {
echo 'ok';
}
},
error: function(jqXHR, textStatus, errorThrown) {
echo 'error';
}
});
The backend is a CodeIgniter PHP application. Here the controller that keep and process the request public function save_report_jsonfile() { $jsonFile = $this->uri->segment('3');
$tmp_file = set_realpath("./file_json/", true).$jsonFile.".json";
// here in the real controller there is the code that save the file_json/
// file_put_contents($tmp_file, json_encode($_POST))
// only for debug purpose
echo json_encode($_POST);
exit;
}
The issue is that in the saved file .json and also in the returned encoded $_POST, I have only a first part of the sent reportData. I don't understand if I have some limit in data posted lenght.
I tried to use console.log($.param(reportData)) in the javascript part and I'm getting a string of about 89.000 chars; actually my php server run 7.3.2 and post_max_size is 8M. If I chech in chrome developing tools, in the Network tab, I see the ajax call and if I explpore its details, in the header information I can see that the "form data" posted are complete and not truncated like that saved to the file.
Hoping I was quite clear. Any idea about the solution?
Kind regards, Matt