Reputation: 6612
In my CMS , I am using Zizaco/entrust/ as an ACL manager and laravel-elfinder as a file manager and uploader.
Both work fine and do not have any problem.
Now, I want to limit access of users that have Specified roles and Permissions to folders that elfinder manage them to upload or list files.
Globally in elfinder configuration file, we can set The dir
where to store the images (relative from public) like this :
return array(
'dir' => ['upload']
);
In this case, All users by any Roles can access it and upload or other commom file operations.
But I want , after user login , if he wants to elfinder , only can access to folder same name as her username and he can not see or access other user folder.
is it possible? if Yes please guide me.
Upvotes: 1
Views: 2814
Reputation: 6612
According @Froxz guidance, I could solve the problem like this:
In Middleware that allow only admin user work with CMS, I wrote :
$username = Auth::user()->username;
if (!File::exists(public_path('upload').'/'.$username)) {
File::makeDirectory(public_path('upload').'/'.$username,0775);
}
Config::set('elfinder.dir',["upload/$username"]);
First , I created a directory same username of user , then set dir
option of elfinder configuration to that folder path.
Upvotes: 2