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.)

screenshot 1

 echo ini_get ('post_max_size');  // 300M
 echo ini_get ('upload_max_filesize');  // 300M

    2 answers 2

    It takes time to complete the download take into account too. Try adding
    ini_set('max_input_time', 300); ini_set('max_execution_time', 300);

    • 60 seconds. Completely for one picture. - Slavik Okara
    • Standard tried to handle? $ im = imagecreatefromstring ($ decodedData); header ('Content-Type: image / png'); imagepng ($ decodedData); imagedestroy ($ decodedData); - Kostiantyn Okhotnyk
    • Thanks, found the problem. At the hosting there was such a chip "ModSecurity". Turned it off and everything fell into place. Everything is fine. - Slavik Okara

    At the hosting there was such a chip ModSecurity . Turned it off and everything fell into place.