Reputation: 41
I have php7 server on Windows2012 in IIS
When i post text data (name fgx in code) 12950 length and below with ajax , it is success and data posted to php form.
When i try 12957+ length data post, its success from ajax but, no any data posted php form.
When i check posted data length in php, it show me undefined .
AJAX POST CODE
$.ajax({
url: 'index.php',
type: 'POST',
data: {
ipdata: fgx
},
success: function(msg) {
$('#info').empty();
$('#info').append(`
<div class="alert alert-success alert-dismissible fade show" role="alert" id="alarma">
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<strong>Datalar post success.<br><br>` + msg + `</strong>
</div>`);
}
});
PHP POST CODE
if( isset($_POST['ipdata'])){
$incdata=$_POST['ipdata'];
echo $incdata;
}
I tried;
ajax post data type = text
ajax post cache = false
ajax proccessdata = false
i checked php post max size and upload max size is 128M
Upvotes: 2
Views: 528
Reputation: 57408
To narrow the search, I would inspect the traffic (either by sniffing it or checking with the browser's debug tools).
If the data does get sent, then I'd try checking the POST data server side some other way:
$data = file_get_contents('php://input');
or, if available,
$data = stream_get_contents(STDIN);
If you're running form-encoded data on a CGI, then that's a problem because neither access is available, I think (but CONTENT_LENGTH envvar should be present). You might be able to install PECL HTTP extension and thus have http_get_request_body()
available, or use the OOP
$req = new http\Env\Request();
$data = $req->getBody();
This should tell you where the data disappears. Making it reappear might be tricky though, unless you can change the server configuration.
Another thing I'd try is to send two variables, the first holding the second's length:
{
fgxc : fgx.length,
ipdata: fgx
}
and then send a fixed string - a sequence of A's, say - in place of fgx. I had it happen to me that a very specific string sequence got edited out of a stream due to a misconfigured firewall that mistook it for a script injection attack.
If 12570 "A"'s pass, and 12570 bytes of fgx don't, then it's something to do with the content - and you might be able to work around it by sending it base64 encoded with btoa()
, say. Then run base64_decode
in the PHP code and you're set.
Upvotes: 1
Reputation: 874
I actually had this problem recently in production. You want to increase your post max size
variable in your php.ini - i had a similar issue where 128MB was not enough even though it was only ~30k characters.
You should also make sure that you increase the memory limit of the PHP script that you are posting to, as you are likely to be also hitting the ceiling there which could also be the problem. Depending on what you're doing in that script you might also want to set time limit to 0 (or a large number).
Upvotes: 0