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

It seems like a quite spread issue then. Right now I don’t have tim to find a solution myself, but it’s been days since a last could sync my calendar and contacts, maybe I’m going back to nc15 for now

solved with this

Is this problem solved automatically with v1.16.7 (2019-09-11) Increased modsecurity bodynofileslimit so larger files can be synced (#993)? Or is this something else oO

it is not about filesize, it’s about wrong tmp directory link

Where / how to fix?

@DystopianLphant fixed it by modifying the tmpdirectory-path in config.php (see here). But it’s not working in my case unfortunately.

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


  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’


‘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!

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


So the initially set is not wrong. It is just not used correctly. And by setting and resetting it is then used correctly? Do I understand this in the right manner? But that also looks like a bug where a developer should take care of it.

Yes, it’s like a reset of the temp folder. I think it is a bug and a developer could have a look.
It seems like a problem occurring on the Raspberry Pi. So it may be connected to having the temp folder located on an external USB drive, but I’m not a web developer.

Does not work for me :frowning: I’m desperate with this problem

For me downgrading to v15 solved, temporarily, the issue. In the meanwhile you could do so

I had the same problem on my NextcloudPi on Odroid HC2. The solution of @malbreitenbach solved the problem in my case.

1 Like

I tried again and even if the tmp path is on the SD card I get the error message (so test step 6). Does anyone have another idea?

Interestingly, I don’t have the problem when I upload using the FlowUpload app. Now I’m completely at a loss. Can someone use this knowledge to draw a conclusion about the problem?

Sad to hear,
for me the problem appeared again, because while an update
was deleted. I fixed it by recreating the folder with correct rights. I hope some developer will have a look into this. Unfortunatly I don’t know if it’s Nextcloud or NextcloudPi related.
Good luck!

Edit: Merry Christmas! :slight_smile:


Also check

In some instances this line:

; Defaults to the system default (see sys_get_temp_dir)
sys_temp_dir = /var/www/nextcloud/data/tmp

Needs Edit to point to /path/toyour/ncdata/tmp
commenting out the line works too.


; Defaults to the system default (see sys_get_temp_dir)
;sys_temp_dir = “/tmp”

seems to be default



it is pointet to the correct path. I commented out anyway and look what will happen.

Thanks malbreitenbach,
I was struggling with the same issue for days. I have upgraded to RPi4B from the 3B+ version and I was no longer able to upload.
Your post made it.
Great and clear step by step explanation

1 Like

fantastic. thanks. I added the path (along to the above changes suggested from @malbreitenbach and I solved all my problems.

1 Like

Many thanks to @malbreitenbach and @OliverV
you saved my day !

1 Like