i know to upload normal type of multiple image.bt here my code is like to upload multiple images with rename image as date and time. but the problem is while uploading multiple image its added only one image.how can i add multiple image by using this code

 $num4 = count($_FILES['mainimage']['name']);
            foreach($_FILES['mainimage']['name'] as $i=>$filename1) 
            {

            $filename1 = $_FILES['mainimage']['name'];
            //$tmpname = $_FILES['mainimage']['tmp_name'][$i];

            function findexts2 ($filename1) 
         { 
         $filename1 = strtolower($filename1) ; 
         $exts1 = split("[/\\.]", $filename1) ; 
         $n1 = count($exts1)-1; 
         $exts1 = $exts1[$n1]; 
         return $exts1; 
         } 

         //This applies the function to our file  
         $ext1 = findexts2 ($_FILES['mainimage']['name']);
         date_default_timezone_set('Asia/Calcutta');
        $ran1 = date('Y-m-d h-i-s'); 

         $ran1 = $ran1.".";
         $target3 = "./upimg/mainimg/";
         $target3 = $target3 . $ran1.$ext1; 
         $result3 = move_uploaded_file($_FILES['mainimage']['tmp_name'], $target3);

        $sql6 = mysql_query("INSERT INTO `offersimagegallery`(`OfferImage`,`offerPath`,spaid) VALUES ('$filename1','$target3','$lid')");
                             //echo $value1;
            }

            $num5 = count($_POST["offerdesc"]);
            //echo $num5;
            foreach($_POST["offerdesc"] as $i=>$value) 
            {
                $value=$_POST["offerdesc"][$i];
                //echo $value;
                $sql7 = mysql_query("INSERT INTO offerdescription (OfferDescription,spaid)VALUES ('$value',$lid)");
            }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.