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

120_'s avatar
Level 1

Laravel 9 storage permission

Hello, I have a problem since I upgraded to laravel 9. When I upload an image to storage, the permissions to access the file are no longer correct.

Example : A user uploads a new image: the image save to this path: storage/app/public/folder/{user_id}/{project_name}/photos/my_photo.jpg

my_photo.jpg has the correct permissions (644)

but all the folders present between public/ and my_photo.jpg were created with permissions 700 instead of 755. The image therefore comes out with a 403 error.

I contacted my host but it doesn't seem to come from them.

Does anyone have a solution to my problem?

Thanks very much !

0 likes
10 replies
120_'s avatar
Level 1

@Sinnbeck thank you very much for your quick response I did not think about it..

'local' => [
            'driver' => 'local',
            'root' => storage_path('app'),
            'permissions' => [
                'file' => [
                    'public' => 0644,
                    'private' => 0600,
                ],
                'dir' => [
                    'public' => 0755,
                    'private' => 0700,
                ],
            ],
        ],

this does not work, but if I do 'private' => 0755 it works.

I don't understand why for files it's 'public' => 644 which is used, but for dir it's 'private' which is used?? Is there a configuration to do somewhere?

ksparkar's avatar

@120_ Were you able to resolve this? Looks to me like files are created 'public' by default and directories are created 'private' by default even if the directory is newly created in the process of creating a new 'public' file

mtdesigners's avatar

I had a similar issue. But it is strange. for some reason some images had the 0700 permission, even though they were all in the same folder in public directory. example: I had to logos. one had 0644 and the other 0700 !? 🤷‍♂️

PS: This happens in production.

andrew_rybachuk's avatar

I have the same issue. Using the "storePublicly" method and correct settings in the filesystems.php. Folders creates with 0700 permission. Temporary solution is only to change the "private" value to the 0755. Is there a bug in the Laravel 9 ?

camiant's avatar

@andrew_rybachuk got the same feeling... storePubliclyAs seems to ignore permissions.file.public and permissions.dir.public disk's settings inside filesystems.php . a temporary workaround could be to set permissions.file.private and permissions.dir.private to the needed octals (0644/0755). if confirmed by others, we should move to this issue over github

https://github.com/laravel/framework/issues/42586

Pierre_AIR's avatar

@camiant I confirm I had the same isue too (Laravel 9.36.2 and PHP 8.1.11) ! With the code below I had permissions 0700 on $path directory (and 0644 on $filename file) :

$path = 'project-' . $user->id;
$request->file('docs')->storePubliclyAs('documents/' . $path, $filename);

But this code worked perfectly :

$path = 'project-' . $user->id;
$request->file('docs')->storeAs('documents/' . $path, $filename, 'public');

The problem is on storePubliclyAs function. The workaround with storeAs and 'public' attribute seems safer than giving 0755 permission on private profile in the filesystem config file.

serdarcevher's avatar

I've encountered this issue as well. In my case, storeAs method with the 'public' parameter didn't work either.

I've solved it by using the Storage facade as:

$path = Storage::putFileAs(
    $main_folder . $folder, 
    $file, 
    $filename,
    [
        'visibility' => 'public',
        'directory_visibility' => 'public'
    ]
);
1 like
aGreenCoder's avatar

I also faced this issue but i solve using change file permission after creation like below code example

$path = 'public/uploads/course/'.$DataToUpdate['image'];
$directoryPath = dirname(storage_path('app/'.$path));
chmod($directoryPath, 0755);

Please or to participate in this conversation.