How to store multiple images paths in database?

Posted 4 months ago by AlexanderKim

I have input with multiple attribute, that allows multiple image uploads. However if it'll be a single image input, then i have no problems to store it's path in a database, but how to store multiple paths in a single column, something like how to insert an array in to a database?

I save images this way:

        if ($request->file('images')) {
            $images = $request->file('images');

            $filenames = Str::lower(
                pathinfo($image->getClientOriginalName(), PATHINFO_FILENAME) . '-' . uniqid() . '.' . $image->getClientOriginalExtension()
            $destination = 'uploads/';
            $images->move($destination, $filenames);

            $product->image = $filenames;

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

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up


Reply to

Use Markdown with GitHub-flavored code blocks.