profile.blade.php
<form action="{{route('user.profile.update',$user)}}" method="post" enctype="multipart/form-data">
@csrf
@method('PUT')
<div>
<img height="100px;" class="img-profile rounded-circle" src="{{$user->avatar}}">
</div>
<br>
<div class="form-group">
<input type="file" name="avatar">
</div>
</form>
web.php
Route::put('admin/users/{user}/update','UserController@update')->name('user.profile.update');
User.php
public function getAvatarAttribute($value){
return asset($value);
}
UserController:
public function update(User $user){
$inputs=request()->validate([
'file'=>['file'],
]);
if(request('avatar')){
$inputs['avatar']=request('avatar')->store('images');
}
$user->update($inputs);
return back();
}
}
This is a profile.blade.php
How to display the image from the public/storage/images in Laravel
If I inspect the image the src is src="http://127.0.0.1:8000/images/dT9gvraL3HbTlHcQly96YwoSJdikNj7fVL1dsIzT.jpeg". How did I do wrong?