Php 通过Laravel 5.8将图像上传至数据库
我正试图通过PHPMyAdmin使用laravel将我的文件夹中的图像上载到DB 在ProductController.php中,存储方法:Php 通过Laravel 5.8将图像上传至数据库,php,laravel-5,Php,Laravel 5,我正试图通过PHPMyAdmin使用laravel将我的文件夹中的图像上载到DB 在ProductController.php中,存储方法: public function store(Request $request) { Product::create($request->all()); $formInput=$request->except('ImgSource'); // validation $th
public function store(Request $request)
{
Product::create($request->all());
$formInput=$request->except('ImgSource');
// validation
$this->validate($request,[
'Name'=>'required',
'Price'=>'required',
'type'=>'required',
'ImgSource'=>'image|mimes:png,jpg,jpeg|max:10000',
]);
// image upload
$image=$request->file('ImgSource');
if($image){
$imageName=$image->getClientOriginalName();
$image->move('images',$imageName);
$formInput['ImgSource']=$imageName;
}
Product::create($formInput);
return redirect()->route('product.index');
}
在web.php中
路由::资源('product','ProductsController');
我使用create.blade.php中的表单
<div class="form-group">
{{ Form::label('ImgSource', 'Image') }}
{{ Form::file('ImgSource',array('class' => 'form-control')) }}
</div>
{{Form::label('ImgSource','Image')}
{{Form::file('ImgSource',array('class'=>'Form control'))}
它存储在表中的产品为
C:\xampp\xampp1\tmp\php46F9.tmp
我应该如何添加正确的图像