Update Image Using PHP Mysqli





<div class="fileupload-preview fileupload-exists thumbnail" style="max-width: 200px; max-height: 225px; line-height: 20px;"><img src="images/<?php echo $row['att_user_photo']?>" height="90" width="90"></div>
                                <div>
                                                                       <input type="file" name="att_user_photo" ></span>
                                    <a href="#" class="btn btn-danger fileupload-exists" data-dismiss="fileupload">Remove</a>
                                   
                                </div>



-----------------------------------------------------------------------------------------------------------------------------------

<?php
      include "include/connection.php";

if(isset($_POST['btn-update']))
{
    extract($_POST);
$name1=$_FILES['att_user_photo']['name'];
$size=$_FILES['att_user_photo']['size'];
$type=$_FILES['att_user_photo']['type'];

$temp=$_FILES['att_user_photo']['tmp_name'];

if($name1)
        {
                    $upload_dir = 'images/';
                    $imgExt = strtolower(pathinfo($name1,PATHINFO_EXTENSION)); // get image extension
                    $valid_extensions = array('jpeg', 'jpg', 'png', 'gif'); // valid extensions
                    $att_user_photo = rand(1000,1000000).".".$imgExt;
                    unlink($upload_dir.$row['att_user_photo']);
                    move_uploaded_file($temp,$upload_dir.$att_user_photo);
        }
        else
        {

                    $att_user_photo=$row['att_user_photo'];           
        }



$upquery= 'update  att_add_user set
                        
                          att_user_name="'.$_POST['att_user_name'].'" ,
                          att_user_gender="'.$_POST['att_user_gender'].'",
                          att_user_mobileno="'.$_POST['att_user_mobileno'].'" ,
                          att_user_address="'.$_POST['att_user_address'].'" ,
                          att_user_photo="'.$att_user_photo.'",
                          att_user_dob="'.$_POST['att_user_dob'].'" ,
                          att_user_jd="'.$_POST['att_user_jd'].'" ,
                          att_user_ld="'.$_POST['att_user_ld'].'" ,
                          att_user_post="'.$_POST['att_user_post'].'" ,
                          att_user_department="'.$_POST['att_user_department'].'" ,
                          att_user_fe="'.$_POST['att_user_fe'].'" ,
                          att_user_se="'.$_POST['att_user_se'].'" ,
                          att_user_te="'.$_POST['att_user_te'].'" ,
                          att_user_be="'.$_POST['att_user_be'].'" ,                          
                          att_user_email="'.$_POST['att_user_email'].'" ,
                          att_user_password="'.$_POST['att_user_password'].'" ,
                          att_user_cpassword="'.$_POST['att_user_cpassword'].'"
                         
                         
                        
                          where att_user_id="'.$_GET['att_user_id'].'" ' ;
                          $upresult = mysqli_query($con,$upquery);
                          if($upresult)
                          {
                             echo '<script type="text/javascript">';
                             echo " alert('User Data Updated Successfully!');";
                             echo 'window.location.href = "userinformation.php";';
                             echo '</script>';
         
                          }
                         else
                         {
                               die(mysqli_error($con));
                               //echo $cQry;
         
                         }
   


}

?>
Previous
Next Post »