You don't have permission to upload or create files here - chown and chmod 755/644 already applied

Nextcloud version (eg, 13.0.0):
Operating system and version (eg, Debian 8):
PHP version (eg, 5.6):

Is this the first time you’ve seen this error? (Y/N): Y

Steps to replicate it:

  1. Copy directory A containing files XYZ to user subdirectory from outside NC (via simple cp)
  2. Run sudo -u www-data php occ files:scan to make it visible
  3. Try adding more files from within Nextcloud
  4. Be prompted with “You don’t have permission to upload or create files here”
  5. Check ownership and find A belonging to root
  6. Fix ownership (to www-data) and permissions of A to 755 and XYZ to 644
  7. Still be prompted with error 4.
  8. Give up

The output of your Nextcloud log in Admin > Logging:
Nothing to see here. (all works fine, please correct if I’m wrong and I’ll provide it)

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):
Nothing to see here either. (all works fine, please correct if I’m wrong and I’ll provide it)

I did this operation to avoid uploading a lot of files and actually it really worked smoothly. It looks like I’m really close… What else should I check? Thanks guys!

Reference: You don’t have permission to upload or create files here
Edit: Errors during scan:

sudo -u www-data php -d  memory_limit=256M occ files:scan 
WARNING: Ignoring invalid value 'share' for parameter 'security'
mkdir failed on directory /var/cache/samba/lck: Permission denied
  1. Never give up

Looks like it was just a matter of time. It now just works. Don’t know why. I’m a little scared, but anyways. Gonna mark as solved. Sorry for bothering you.

how we can solve this problem you dont have permission to upload or create files here kindly tell as son as possible