Cannot upload files, error "expected filesize 5160954 got 8192" appears

I found a solution, which is working on two Raspberry Pis. Use it with caution, I’m just a beginner on this topic.

Procedure

  1. Locate config.php

cd /var/www/nextcloud/config

  1. Edit config.php

nano config.php

  1. Change line for tempdirectory

‘tempdirectory‘ => ‘/media/USBdrive/ncdata/tmp’
(example)

to

‘tempdirectory‘ => ‘/var/www/nextcloud/data/tmp’

The new folder is located on the SD-card and should have following rights

drwxr-xr-x 2 www-data www-data

  1. Save and Exit by Ctrl+S and Ctrl+X

  2. Reboot the server

  3. Test it by transferring a larger file (should work now)

  4. Undo the changes in config.php and reboot again (now the temp directory should be located on the USB drive again and transferring should work)

Best wishes!

EDIT:
Also check /etc/php/7.3/fpm/php.ini as mentioned from @OliverV below.

7 Likes