In my case, i was correctly updating these 3 values upload_max_filesize , post_max_size (larger than upload_max_filesize ) and memory_limit in the php.ini config for my PHP version e.g. 8.1. But I was still having the same error. Then i noted I needed to make the same changes in the php.ini for PHP FPM e.g. /etc/php/8.1/fpm/php.ini. Then restart php8.1 and php8.1-fpm services.
Once I did that, everything worked well.
Extra notes:
Nginx: Remember to check the value of client_max_body_size in Nginx config
Modsec: Remember to check SecRequestBodyLimit and SecRequestBodyNoFilesLimit values in Modsec config.
Remmeber to restart services after these changes.