我正在学习创建一些论坛,但是当我更新照片配置文件时,它无法显示。当我尝试检查元素时,它说:
“加载资源失败:服务器响应状态为 404(未找到)”
这是我的控制器:
public function update()
{
$avatar = request()->file('avatar');
$avatar_validate = 'image|mimes:jpeg,png,jpg,svg|max:2048';
request()->validate([
'username' => 'required|alpha_num|min:6|max:20|unique:users,username,' . auth()->id(),
'name' => 'string|required',
'avatar' => $avatar ? $avatar_validate : "",
]);
$hash = auth()->user()->hash;
$avatar_name = $avatar->storeAs('profile-picture', "{$hash}.{$avatar->extension()}");
auth()->user()->update([
'username' => request('username'),
'name' => request('name'),
'avatar' => $avatar_name,
]);
return redirect()->route('users.show', auth()->user()->usernameOrHash());
}