I've been playing with multiple files and I've successfully managed how to upload multiple files (in my case images) into the public/storage folder in Laravel, but I want to upgrade the method to dynamically create a folder based on user ID.
In a nutshell, when user select let's say 10 images, hit the submit button, a folder with his ID will be created and then those 10 images will end up in this folder.
This is my function to store the images:
public function store(Request $request) {
$files = $request->file('file');
if(!empty($files)):
foreach($files as $file):
Storage::disk('photos')->put($file->getClientOriginalName(), file_get_contents($file));
endforeach;
endif;
}
And the filesystem:
'photos' => [
'driver' => 'local',
'root' => public_path('../public/storage'),
],
Now I am stuck here and can't get it how to make it working. Would appreciate any help.