I'm trying to upload image from my folders to DB by PHPMyAdmin using laravel
inside ProductController.php the store method:
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');
}
and in the web.php
Route::resource('product','ProductsController'); and I use the form in create.blade.php
<div class="form-group">
</div>
It stores in the table products as C:\xampp\xampp1\tmp\php46F9.tmp what should I do to add correct images?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire