I'm currently working with file uploads and trying different ways to get larger files to my server.
However I've found this answer and dont understand why this is ignoring the post_max_size/upload_max_filesize of the php.ini.
I'm using the following code for testing, which work but I don't understand why the php.ini seems to be ignored.
Javascript part:
var reader = new FileReader();
reader.readAsArrayBuffer(file); // alternatively you can use readAsDataURL
reader.onloadend = function (evt)
{
// create XHR instance
xhr = new XMLHttpRequest();
// send the file through POST
xhr.open("POST", 'upload.php', true);
// make sure we have the sendAsBinary method on all browsers
XMLHttpRequest.prototype.mySendAsBinary = function (text)
{
var data = text;
if(typeof window.Blob == "function")
{
var blob = new Blob([data]);
}
else
{
var bb = new (window.MozBlobBuilder || window.WebKitBlobBuilder || window.BlobBuilder)();
bb.append(data);
var blob = bb.getBlob();
}
this.send(blob);
}
// start sending
xhr.mySendAsBinary(evt.target.result);
};
PHP part:
// read contents from the input stream
$inputHandler = fopen('php://input', "r");
$buffer = fgets($inputHandler, 4096);
// do some stuff and keep reading with $buffer = fgets($inputHandler, 4096);
So my question here is: Why does my upload.php receive files if they're several GB in size even if post_max_size is limited to 8MB and upload_max_filesize is limited to 2MB?