Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

PHP 

Multi image upload

Hey HF,

so I need to create an image upload which is attached to a product, so if you load the product from the DB, you're able to see the images.

I've got it working with 1 image at a time but I need it to be a multi image upload.

The code below shows my current upload script:

Upload.php


uploader.php



Can anybody help me to create a multi image uploader?
So your pulling product informations from a database and now you want to upload those informations + a new picture added for each product to something else?
Maybe this will help :
https://www.youtube.com/watch?v=q6l7KnRJ...-&index=54
Back.

(Aug 8, 2017 08:05 AM)d4ne Wrote:  So your pulling product informations from a database and now you want to upload those informations + a new picture added for each product to something else?

No, people can add their product to the database. After that they chose their product and upload the images for it.
Well a example would be (Select multiple images at once inside the selection window):



Source: https://stackoverflow.com/a/12006515
Thanks, but I need it to be working within mysql, so I can add the product ID to it in order to load the image once the product page is loaded. (See the single image upload)
(Aug 8, 2017 08:42 AM)N1l0c Wrote:  Thanks, but I need it to be working within mysql, so I can add the product ID to it in order to load the image once the product page is loaded. (See the single image upload)

Just take above script, edit within the for loop your sql stuff and you'll be fine.

Code
// Loop through each file
    for($i=0; $i < $total; $i++)
    {
        //Get the temp file path
        $tmpFilePath = $_FILES['upload']['tmp_name'][$i];

        //Make sure we have a filepath
        if ($tmpFilePath != ""){
            //Setup our new file path
            $newFilePath = "./uploadFiles/" . $_FILES['upload']['name'][$i];

            //Upload the file into the temp dir
            if(move_uploaded_file($tmpFilePath, $newFilePath)) {
                   $stmt = $database->prepare("INSERT INTO `upload` (`name`,`type`, `size`, `p_id`) VALUES ( ?,  ?, ?, ?)");
        $stmt->bind_param('ssss', $file, $file_type, $file_size, $p_id);
        $stmt->execute();
        $stmt->close();
            }
        }
    }

Something like that
工 ᗪㄖ𝓝丶七 丂🝗🝗 ⼕ㄖ㇄ㄖ尺⸝ チㄩセㄩ尺🝗 ⻏㇄闩⼕长 PINK!
Yea as Fresku already answered, i just posted a example. The rest should be done easily.
Ouh, yeah. I got it working. Looks like shit but works.

I appreciate your help guys!
(Aug 8, 2017 08:51 AM)N1l0c Wrote:  Ouh, yeah. I got it working. Looks like shit but works.

I appreciate your help guys!

No problem for the help.

You can control the looks and feels of your webpage by HTML and CSS, I assume you already do know that.
工 ᗪㄖ𝓝丶七 丂🝗🝗 ⼕ㄖ㇄ㄖ尺⸝ チㄩセㄩ尺🝗 ⻏㇄闩⼕长 PINK!


Possibly Related Threads...
Thread / Author Replies Views Last Post
[The Brotherhood] by VinavilMar 27, 2026 09:05 AM 25 859 Mar 27, 2026 09:05 AM
Last Post: Vinavil
[PHP] by NuminousAug 24, 2017 08:57 AM 5 270 Aug 24, 2017 08:57 AM
Last Post: Ceanko
[PHP] by EssenceDec 12, 2016 06:18 PM 2 166 Dec 12, 2016 06:18 PM
Last Post: Essence