Nov 15, 2022
0
Level 8
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?
Please or to participate in this conversation.