2

Im loosing mind. I upload files via laravel API, they are stored in folder and file always get permission 644, is there any way how to store files as 775 ?

can i somehow add this to my function ?

 (0755, true, true) 

function for store files:

 $result=$request->file('file_path')->store('apiFiles/'.$idParameter); 

thanks for any help

1
  • its recommended files to be 644/664 and folder 755/775 Commented Nov 4, 2020 at 11:56

2 Answers 2

6

In laravel you can use 'public' or 'private' disks and set the permissions options in the config file filesystems.php

https://laravel.com/docs/8.x/filesystem#permissions

The public visibility translates to 0755 for directories and 0644 for files. You can modify the permissions mappings in your filesystems configuration file:

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

You can then store files with specific visibility like it suggests here https://laravel.com/docs/8.x/filesystem#file-visibility

Or you can use the built in php function chmod()

https://www.php.net/manual/en/function.chmod.php

Sign up to request clarification or add additional context in comments.

1 Comment

Such a nice thorough answer !!!
2

you can change permission of file after creating them by chmod command like this:

$result=$request->file('file_path')->store('apiFiles/'.$idParameter); chmod('file path',0775); 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.