我正在尝试更新用户个人资料图片。但是每次我都会遇到错误,例如-
RuntimeException SplFileInfo::getSize(): stat failed for /tmp/php8uXhSg
每当我在save()方法之前执行dd()时,一切看起来都很好。但是在保存记录时它会抛出错误。
以下是我的控制器的代码 -
用户控制器.php
public function update(UserRequest $request, $slug) {
if($request->has('profile')) {
$profile = $request->profile;
$extension = $profile->getClientOriginalExtension();
$profile_name = auth()->user()->username.time().'.'.$extension;
$path = public_path('storage/uploads/avatars');
$profile->move($path, $profile_name);
auth()->user()->profile = $profile_name;
}
auth()->user()->save();
return back()->with(['mesg', 'Successfully Uploaded.']);
}