I am using ajax file upload from this answer Sending multipart/formdata with jQuery.ajax and JavaScript code looks like this:
   function addAiFile(order_id) {
        var data = new FormData();
        data.append('order_id', order_id);
        jQuery.each(jQuery('.ai-file_upload')[0].files, function(i, file) {
            data.append('file-'+i, file);
        });
        var url='<?php echo $addAiFile; ?>';
        url=url.replace(/amp;/g, '');
        console.log(...data)
        jQuery.ajax({
            url: url,
            data: data,
            cache: false,
            processData: false,
            method: 'POST',
            type: 'POST', // For jQuery < 1.9
            success: function(answer){
                $('#ai-modal .modal-body').html(answer);
            }
        });
    }
On FrontEnd when i trigger this functoin i'm getting correct log result. But on BackEnd my $_FILES array is empty. This happens only for some files and i can't find what triggers this.
Here is my Code:
public function addAiFile(){
        $target_dir = "./";
        $target_file = $target_dir . basename($_FILES["file-0"]["name"]);
        $uploadOk = 1;
        $imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
        echo $target_file;
        print_r($_FILES);
        echo "<br>" . $_SERVER['CONTENT_LENGTH']/1000000 ; 
        echo "<br>" . ini_get('post_max_size'); 
        echo "<br>" . ini_get('upload_max_filesize');
        print_r(pathinfo($target_file));
        die();
}
If there is an error php prints this:
./-0.Array ( )
34.860443
80M
80M Array ( [dirname] => ./ [basename] => -0. [extension] => [filename] => -0 )
If there is no error with a file i'm getting this
./oaid.png Array ( [file-0] => Array ( [name] => oaid.png [type] => image/png [tmp_name] => /tmp/php57HOx7 [error] => 0 [size] => 16554 ) )
0.016836
80M
80M Array ( [dirname] => ./ [basename] => oaid.png [extension] => png [filename] => oaid )
I would post a file here as an example, but it's 30mb. Also it's important to note that it happens only for some files. How can i fix this?
 
    