Error while uploading files to Nextcloud
Error message:
"Expected file size of ... bytes, but ... bytes read (by Nextcloud client) and written to Nextcloud storage..."
The problem is that the location of the data directory of Nextcloud was changed, but the path was not adjusted in the system's PHP settings and points to the old location, which no longer exists.
Solution:
In the configuration file
/etc/php/8.1/fpm/php.ini
Adjust both entries
sys_temp_dir = /var/www/nextcloud/data/tmp
and
upload_tmp_dir = /var/www/nextcloud/data/tmp
to the current path.
Then restart the server (just restarting the Apache2 service wasn't enough for me)