在Laravel中更新表后如何修复我的错误

时间:2019-11-08 22:53:51

标签: laravel-6

在Laravel中更新并上传图片后收到错误消息。

  

InvalidArgumentException

Screenshot of error

控制器

public function actedit(Request $Request, $id)
{
    $user = User::find($id);

    $user->title = $Request->input('title');
    $user->description = $Request->input('description');
    $user->url = $Request->input('url');
    $file = $Request->file('avatar');
    if (!$file) {
        return redirect()->route('editprofile')->with('alert', 'foto harus diisi!');
    }
    $file_name = $file->getClientOriginalName();
    $path = public_path('/img');
    $file->move($path, $file_name);
    $user->image = 'public/img/'.$file_name;
    $user->save();

    return redirect('profile/'.$id);
}

路线

Route::post('/edit/{id}', 'HomeController@actedit')->name('actedit');

0 个答案:

没有答案