Using laravel 5.3, I am trying to retrieve an image in a view. How I could do this?
folder structure: storage/app/avatard
Here is the code:
public function storeAvatar(Request $request, $username)
{
$user = User::where('name', $username)->first();
$avatar = $request->file('avatar')->store('avatars');
$avatar = explode('avatars/', $avatar);
$user->user_setting()->updateOrCreate(
['user_id' => $user->id],
['avatar' => $avatar[1]]
);
return back();
}
This is how the image path is saved in the database:
/users/avatar/default.png
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…