错误
出现消息“调用成员函数getClientOriginalExtension()为null时引发”的Symfony \ Component \ Debug \ Exception \ FatalThrowableError
堆栈跟踪:
控制者
public function store(Request $request)
{
$this->validate(request(),[
'title' => 'required',
'image' => 'image|mimes:jpeg,png,jpg,gif,svg',
'body' => 'required',
]);
$imageName = time().'.'.$request->image_file->getClientOriginalExtension();
$request->image->move(public_path('image'), $imageName);
auth()->user()->publish(
new Post(request(['title','body']))
);
session()->flash('message', 'your post has now been published');
return redirect('/');
}
似乎应该使用,image
因为您正在验证image
而不是image_file
:
$request->image->getClientOriginalExtension()
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句