I am trying to upload file from form page. If I post the photo files it show me on database online and on the folder only one of them.
This is from page:
<form method="post" action="post_data.php" enctype="multipart/form-data">
     <table align="center" class="monjey-tb">
    <tr>
    <td>
    <label><span style="color:red">*</span>full name</label>
    <input type="text" name="d_name" class="form-control" required /></td>
    </tr>
    <tr>
    <td><br><label><span style="color:red">*</span>ID No.</label><input type="text" name="d_cpr"  class="form-control" required /></td>
    </tr>
    <tr>
    <td><br><label><span style="color:red">*</span>Address</label><input type="text" name="d_address"  class="form-control" required /></td>
    </tr>
    <tr>
    <td><br><label><span style="color:red">*</span>Mobile</label><input type="text" name="d_mobile"  class="form-control" required /></td>
    </tr>
    <tr>
                          <td><br>  <label><span style="color:red">*</span>Level</label> <div>
                    <select name="d_level" class="form-control" required>
                            <option value="1">1</option>
                            <option value="2">2</option>
                            <option value="3">3</option>
                    </select>
                    </div>
    </td>
    </tr>
    <tr>
    <td><br><label><span style="color:red">*</span>Total</label><input type="text" name="d_total"  class="form-control" required /></td>
    </tr>
    <td><br><label><span style="color:red">*</span>Photo1</label><input type="file" name="file"  class="form-control" required/></td>
    <tr>
    </tr>
    <td><br><label>photo2</label><input type="file" name="pphoto"  class="form-control"/></td>
    <tr>
    </tr>
    <td><br><label><span style="color:red">*</span>photo3</label><input type="file" name="certificate" class="form-control" required/></td>
    <tr>
    <td style="text-align: center"><br><button type="submit" name="submit"><strong class="j1">submint</strong></button></td>
    </tr>
    </table>
    </form>
and the post page is
<?php
include_once 'dbconfig.php';
if(isset($_POST['submit']))
{
 //extract($_POST);
$d_name = $_POST['d_name'];
$d_cpr = $_POST['d_cpr'];
$d_address = $_POST['d_address'];
$d_mobile = $_POST['d_mobile'];
$d_level = $_POST['d_level'];
$file = rand(1000,100000)."-".$_FILES['file']['name'];
$certificate = rand(1000,100000)."-".$_FILES['certificate']['name'];
$pphoto = rand(1000,100000)."-".$_FILES['pphoto']['name'];
$file_loc = $_FILES['file']['tmp_name'];
$file_loc2 = $_FILES['certificate']['tmp_name'];
$file_loc3 = $_FILES['pphoto']['tmp_name'];
$file_size = $_FILES['file']['size'];
$file_type = $_FILES['file']['type'];
$folder="uploads/"; 
 // variables for input data
$new_size = $file_size/1024; 
$new_file_name = strtolower($file);
$final_file=str_replace(' ','-',$new_file_name);
if(move_uploaded_file($file_loc,$folder.$final_file))
 {
    if(move_uploaded_file($file_loc2,$folder.$final_file)){
        if(move_uploaded_file($file_loc3,$folder.$final_file)){
 // sql query for inserting data into database
        $sql_query = "INSERT INTO users(d_name,d_cpr,d_address,d_mobile,d_level,file,type,size,certificate,pphoto)
        VALUES('$d_name','$d_cpr','$d_address','$d_mobile','$d_level','$file','$file_type','$file_size','$certificate','$pphoto')";
 mysql_query($sql_query);
    header("Location: redir.php");    
// sql query for inserting data into database
 }
}
}
}
?>
The problem on the  post page near if(move_uploaded_file($file_loc,$folder.$final_file)).
I have 3 file
$file_loc
and $file_loc2
and $file_loc3
 
     
    