Support the ongoing development of Laravel.io →
Laravel Input

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');

}`
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Save doopra Joined 31 Dec 2022

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.