Welcome Guest, Not a member yet? Register   Sign In
Want to upload three images from upload option in a single form.
#1

Want to upload three images from the upload option in a single form. After selecting the files against each option. The file too should be uploaded to MySQL Database, which I am not able to complete. Please assist
Reply
#2

(This post was last modified: 11-12-2020, 01:25 PM by captain-sensible.)

(11-11-2020, 02:51 AM)[email protected] Wrote: Want to upload three images from the upload option in a single form. After selecting the files against each option. The file too should be uploaded to MySQL Database, which I am not able to complete. Please assist
i'm on CI4 but one approach might be three file input fields :

something along the lines of:

<input type="file" name="Image1" size="20" id="gallery" required ="true"/>

<input type="file" name="Image2" size="20" id="gallery" required ="true"/>

<input type="file" name="Image3" size="20" id="gallery" required ="true"/>

IN CI4 in a controller you can get info from form via:

$file =  $this->request->getFile('Image1');
$nameImgFile= $file->getName();


Now i upload  images for my site. All you need in a db is name of image and where its stored.

so for instance say an Image called waiter,gif was uploaded  to galleryImages and in a db in a field (text) called "image" the dat in a field is just  "waiter.gif" 


you get results from db and to show it in a view , it would be something like:

Code:
foreach ($result as $stuff)
{
<img src =".base_url('galleryImages')."/".$stuff['image'].">
}

in the above we know all images are stored in a directory called "galleryImages" which itself is in public. So we put together the 2 galleryImages and whats in db. CI3 will be different but you might get idea from approach .If you go to one of my web and click Art & Design you will see theory in action
Reply
#3

(This post was last modified: 11-13-2020, 01:38 PM by InsiteFX.)

You do not want to save the image file to the database, save the image files url link
to the database.

Here is an example on how to do it.

Codeigniter 4 - Upload Multiple File and Image Example
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#4

(This post was last modified: 11-17-2020, 05:07 AM by nicolas33770.)

Try https://www.dropzonejs.com/ I use it with CI3 and it's really cool ?
Reply




Theme © iAndrew 2016 - Forum software by © MyBB