createFile() permissions issue

Locally, the code works fine to create a file.
When I upload the code to the hosting, I seem to be getting the error: “The file cannot be created”.

Can someone help?
I tried changing the permissions of my folder on the hosting, but still the same issue.

$file = $page->createFile([
   'filename' => '666.pdf',
   'source'   => $pdfName,
   'parent'   => $page,
], true);

The permission exception means, that there’s no authenticated user. Maybe you are logged into the panel locally and that’s why it works there.

@bastianallgeier And how can I create a file without being logged in? Any visitor should be able to create a file…

You might use $kirby->impersonate() | Kirby CMS in your code to add permissions that usually an authenticated user would have for scenarios where you don’t have any authenticated user.