Hello. There is a JS code:
// Create a new FileReader instance
var fileReader = new FileReader ();
// Initiate the FileReader function
fileReader.onload = (function (file) {
return function (e) {
// Put the image URI into an array
dataArray.push ({bdID: bdID, pgID: pgID, acID: acID, name: file.name, value: this.result});
addImage ((dataArray.length-1));
};
}) (files [index]);
// Produce reading the image by URI
fileReader.readAsDataURL (file);
Next, I send the array via AJAX to the PHP file handler where via the function
// Select the data
$ file = $ _POST ['value'];
$ data = explode (',', $ file);
// Decode the data encoded by the MIME base64 algorithm
$ encodedData = str_replace ('', '+', $ data [1]);
$ decodedData = base64_decode ($ encodedData);
$ randomName = substr_replace (sha1 (microtime (true) * (rand (1, 9) * 0.1)), '', 12). '.'. $ mime;
// Create an image on the server
file_put_contents ($ uploaddir. $ randomName, $ decodedData)
On LAN (OpenServer) everything worked fine, but it was enough to upload it all to the server - files larger than 1MB are loaded in their own way. They are loaded in several percents (see screenshot 1).
Screenshot 1. (Left picture weighing 0.4MB, right 1.2MB.)
echo ini_get ('post_max_size'); // 300M
echo ini_get ('upload_max_filesize'); // 300M
