我的表格:
<form action="{{route('settings.update')}}" method="POST">
@csrf
<div class="col-sm-3">
<div class="form-group">
<label for="avatar">Upload a new one:</label>
<input type="file" id="pic" name="pic"/>
</div>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary">Upload avatar</button>
</div>
</form>
我的控制器:
public function update_settings($request)
{
$this->validate($request, [
'pic' => 'required|image'
]);
$path = $request->image->store('/img/');
Auth::user()->image = $path;
return view('pages.settings');
}
错误:
Too few arguments to function App\Http\Controllers\PagesController::update_settings(), 0 passed and exactly 1 expected
我在 $request 中只传递图像文件,但由于某种原因控制器看不到它,我做错了什么?
慕田峪9158850