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.


In the configuration file

Adjust both entries

sys_temp_dir = /var/www/nextcloud/data/tmp
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)