To resolve this, ensure that the wp-content/uploads directory and its parent directories have the correct ownership. The Apache user (commonly www-data or apache) should be the owner of these directories. You can use the following command in the terminal:
sudo chown -R www-data:www-data /var/www/html/wordpress/wp-content/uploads
This recursively changes ownership to the Apache user. After applying this command, try uploading images, installing plugins, and updating WordPress again. If the issue persists, check the file and folder permissions to ensure that they are set to allow the Apache user to read, write, and execute. You can use the following command:
sudo chmod -R 755 /var/www/html/wordpress/wp-content
For further explanation you can go through the wpbeginner article:https://www.wpbeginner.com/beginners-guide/how-to-fix-file-and-folder-permissions-error-in-wordpress/