GIF89a
<?php ob_start(); ini_set('error_reporting', E_STRICT); include("connect.php"); mysqli_set_charset($conn,'utf8'); date_default_timezone_set('Asia/Kolkata'); $user_id=$_POST['user_id']; // target directory $target_dir='prod_image/'.mt_rand(100,987).date('his').trim($_FILES["image"]["name"]); $url='admin.cpanel/'.$target_dir; // Check if file already exists if (file_exists($target_dir)) { echo '<script>alert("Image already exist | try another file");</script>'; echo '<script>window.location.href="addremoveproduct.php";</script>'; } else { $FileType = strtolower(pathinfo($target_dir,PATHINFO_EXTENSION)); if($FileType != "png" && $FileType != "jpg" && $FileType != "jpeg" ) { // file format not supportedonly images allows echo '<script>alert("Invalid image format");</script>'; echo '<script>window.location.href="profile.php";</script>'; } else { move_uploaded_file($_FILES["image"]["tmp_name"],$url); $sqlUP="UPDATE `app_admin` SET `image`='".$target_dir."' WHERE `sr`='".$user_id."'"; $rsUP=mysqli_query($conn,$sqlUP); if($rsUP>0) { echo '<script>alert("Profile photo has been updated");</script>'; echo '<script>window.location.href="profile.php";</script>'; } else { echo '<script>alert("Unable to update profile photo");</script>'; echo '<script>window.location.href="profile.php";</script>'; } } } ?>