Multiple Images Uploads Step by Step

 
1
<input type="file" name="image[]" id="form-field-2" placeholder="Select News Image For Uploading" class="col-xs-10 col-sm-5" required multiple="multiple" />
 
 
<input type="file" name="image[]" id="form-field-2" placeholder="Select News Image For Uploading" class="col-xs-10 col-sm-5" required multiple="multiple" />
 
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
        include "connection.php"; // include your database connection file
                                 
        if(isset($_POST['submit']))
            {
                    extract($_POST);
                    $i=0;                                          
                $total = count($_FILES['image']['name']);
                                             
                for($i=0; $i<$total; $i++) {
                                               
                 $tmpFilePath = $_FILES['image']['tmp_name'][$i];                                            
                 if ($tmpFilePath != ""){
                                                 
                 $img=md5(time());
                 $newFilePath ="".$img.$_FILES['image']['name'][$i];                                               
            if(move_uploaded_file($tmpFilePath, "../event/".$newFilePath)) {
                                                   
         $query=mysqli_query($con,"insert into event_photo(ep_e_id,ep_photo) values ('$title','$newFilePath')") or die(mysqli_error($con));
                                                 
          if($query==1) 
                                                 
            {
                                                     
 echo '<script type="text/javascript">';
                                                      
echo 'alert("Event Image Uploaded Successfully...");';
echo 'window.location.href = "add_event_photo.php";';
         echo '</script>';
     }
        else
        {                                                   
            echo"".mysqli_error($con);
                                     
             }
                                         
    }
                                             
elseif(isset($_POST['cancel']))
                                             
{
                                                     
 echo '<script type="text/javascript">';
                                              
                                                     
 echo 'window.location.href = "add_event_photo.php";';
                                                    
  echo '</script>';
                                         
    }
                                             
    }
                                               
                                             
  }            
                             
                                             
}
    
 
 
<?php
        include "connection.php"; // include your database connection file
                                
        if(isset($_POST['submit']))
            {
                    extract($_POST);
                    $i=0;                                           
                $total = count($_FILES['image']['name']);
                                            
                for($i=0; $i<$total; $i++) {
                                              
                 $tmpFilePath = $_FILES['image']['tmp_name'][$i];                                             
                 if ($tmpFilePath != ""){
                                                
                 $img=md5(time());
                 $newFilePath ="".$img.$_FILES['image']['name'][$i];                                                
            if(move_uploaded_file($tmpFilePath, "../event/".$newFilePath)) {
                                                  
         $query=mysqli_query($con,"insert into event_photo(ep_e_id,ep_photo) values ('$title','$newFilePath')") or die(mysqli_error($con));
                                                
          if($query==1)  
                                                
            {
                                                    
 echo '<script type="text/javascript">'; 
                                                     
echo 'alert("Event Image Uploaded Successfully...");'; 
echo 'window.location.href = "add_event_photo.php";';
         echo '</script>';
     }
        else
        {                                                    
            echo"".mysqli_error($con);
                                    
             }
                                        
    }
                                            
elseif(isset($_POST['cancel']))
                                            
{
                                                    
 echo '<script type="text/javascript">'; 
                                             
                                                    
 echo 'window.location.href = "add_event_photo.php";';
                                                   
  echo '</script>';
                                        
    }
                                            
    }
                                              
                                            
  }             
                            
                                            
}
    

Comments

Post a Comment

Popular posts from this blog

How to seperate character from string in php

How to Delete record using PHP Ajax

Uploads Only 10 files in month step by step