1 year ago

How to save an image and retrieve it in view form in laravel

Posted 1 year ago by AbdulBazith

Guys i am working with a project.

i am having a form which asks details about vendor name, id, address and stores in db and the i viewed it in view.blade as tabular format.

Now i need to add image of the vendor too

How can i perform this?

i referred in google and some says to store in public folder, some says can directly store in db, some says just store the path in db.

which is better.

whats my objective is to get the image from the user and store it in DB and thenin view.blade to display the details as well as the image also

this is what my controller to get the details of the vendor,



       //inserting values

        $vendor_details=new vendor_details;

        $vendor_details->vendor_id = trim($request->vendor_id);


         Session::flash('success',' Vendor Data Entered succesfully');

       return redirect()->route('Vendor_details.create' );

in this additionally i need to insert the image also

this is what my code in controller view.blade

  $ven = Vendor_details::orderBy('created_at','desc')->paginate(5);

         return view('Vendor_details.view')->withven($ven);

and this is what my view.blade

            @foreach($ven as $vens)

                    <td>{{ $vens->vendor_name }}</td>
                    <td>{{ $vens->ven_loc }}</td>
                    <td>{{ $vens->ven_area }}</td>
                    <td>{{ $vens->ven_booth }}</td>
                    <td>{{ $vens->vendor_phno }}</td>
                    <td>{{ $vens->vendor_address }}</td>
                    <td>{{ $vens->rate_per_litre }}</td>
                    <td>{{ $vens->note }}</td>

Kindly some one help please

Please sign in or create an account to participate in this conversation.