n0tttrui
2 years ago
1684
8
Laravel

get storage url...

Posted 2 years ago by n0tttrui

How can i get the url of storage avatar ? my code:

public function uploadAvatar () 
    {
        $avatar = request()->file('avatar')->store('avatars');
        $user = \Auth::user();
        $user->avatar = $avatar;
        $user->save();
        return back();
    }

if i use this:

{{ Storage::url(Auth::user()->avatar)}}

// return: /storage/avatars/fcdfa45ab020a63d95dd1f13b8e0f693.jpeg
// and not something like:
// http://sdsdsd.com/avatars/fcdfa45ab020a63d95dd1f13b8e0f693.jpeg
//why ?

Anyone can help ?

Please sign in or create an account to participate in this conversation.