slickness
slickness

Reputation: 246

create folders when the picture is uploaded laravel

I want to save the uploads from the users in a path with the user ID. How can I integrate the ID into the path that automatically creates the folder?

if($r->hasFile('avatar'))

  {
    Auth::user()->update([
      'avatar'=> $r->avatar->store('public/$id/avatar')
    ]);
  }

Upvotes: 0

Views: 37

Answers (1)

mwal
mwal

Reputation: 3113

You need double quotes if you want your id variable to be interpolated there:

'avatar'=> $r->avatar->store("public/$id/avatar")

Upvotes: 2

Related Questions