The other data are saved on the database but the images are not saved `public function add_product(Request $request) { $product=new product;
$product->title=$request->title;
$product->description=$request->description;
$product->price=$request->price;
$product->quantity=$request->quantity;
$product->discount_price=$request->discount_price;
$product->category=$request->category;
$image=$request->image;
if($request->hasFile('image')){
foreach($request->file('image')as $image){
$imageName = $product['title'].'-image-'.time().rand(1,1000).'.'.$image->extension();
$image->storeAs('product',$imageName);
}
}
$product->save();
return redirect()->back()->with('message','Product Added Successfully');
}`
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community