'Wordpress Ajax Request with file 100kb+ file doesn't pass to endpoint

So, I have a simple ajax request that submits a file for further processing by wordpress:

//JS
var data = new FormData();
data.append('file', file);
data.append('ftype', ftype);
data.append('meta', meta);
data.append('action', 'updatefiles');
var value = jQuery.ajax({
                url: ajaxurl,
                data: data,
                type: 'POST'
    });


//PHP
public function __construct()
{
   add_action('wp_ajax_updatefiles', [$this, 'updatefiles']); 
}
    
public function updatefiles()
{
   error_log('updatefiles reached');
   ///other logic
}

It used to work on multiple projects, but now for some unknown reason when I submit a .png file it doesn't reach the function (the very first line with error_log is not executed). with a .jpg everything works.

Network tab shows that a request went to server, but aint got a response:

//PNG file submission

png file submission

//JPG file submission

jpg file submission

UPDATE ---------------------------------

After further trying it around I found our it was actually image size, not image type, that was not passing through to the server.

It turned out any image above 100kb doesn't reach the server.

I double checked nginx.conf and php.ini for upload settings, but they seem legit:

nginx.conf
client_max_body_size            12m;

php.ini
post_max_size = 14M
upload_max_filesize = 12M

Also, I enabled both access.log and error.log for nginx, and here what they output:

access.log
127.0.0.1 - - [09/Feb/2022:20:23:35 +0300] "POST /wp-admin/admin-ajax.php HTTP/1.1" 408 0 "http://site.local/mypage/440/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.82 Safari/537.36" "-"

error.log
2022/02/09 20:23:15 [warn] 701#701: *1 a client request body is buffered to a temporary file /var/lib/nginx/body/0000000002, client: 127.0.0.1, server: site.local, request: "POST /wp-admin/admin-ajax.php HTTP/1.1", host: "site.local", referrer: "http://site.local/mypage/440/"

It seems it doesn't proceed past nginx temporary file, but I dont have an idea why yet.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source