I'm learning laravel but I have problem now with the image, I want it to save it in storage/app/public/avatar so I can show it, but it keep saving it in storage/app/avatar
I write this in the .env
FILESYSTEM_DRIVER=public
And then I generate the storage link
php artisan storage:link
but still the same, every time I upload a photo it saving it in storage/app/avatar
Anyone can help me?
In filesystems.php
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
Here :
$attributes['avatar'] = request('avatar')->store('public/avatars');
In USer.php
public function getAvatarAttribute($value)
{
return asset($value);
}
this method was working correctly when i was using a random avatar link, but now it show nothing, i check my database and the link is there and it's right
public function getAvatarAttribute($value)
{
asset('storage/avatars/'.$image->name);
}
$attributes['avatar'] = request('avatar')->store('public/avatars');
In the controller, update method:
$user->update($attributes);
$user->password = Hash::make($user['password']);
$user->save();
return redirect($user->path());
In the show.blade
<img
src= "{{ $user->avatar }}"
alt=""
class="rounded-full mr-4 absolute"
style="width: 150px; left: calc(50% - 75px); top: 300px"
>
but the src become "(unknown)"
$image->move($filepath,$filename);
– Doroassert('/avatars/filename.file-ext')
– Doro