Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Ligonsker's avatar

No permissions when creating new folders in storage folder

I am storing user uploaded files in /storage/files/<user_id>/ folder.

I'm using nginx

But if the user hasn't uploaded anything yet, then the folder doesn't exist yet. When I use the store method:

$path = $request->file('files')->store($user_id);

It creates the folder and successfully saves the files there.

But, I no longer have permission for that newly created folder so I believe I won't be able to access it later.

How can I create these new folders and have permissions on them?

Currently in order to check the files I manually run the following every time:

sudo chown -R $USER:www-data storage
chmod -R 775 storage

But how can I get correct permissions every time?

0 likes
0 replies

Please or to participate in this conversation.