if(isset($_POST['user_image_id'])){
$upload_image_id = $_POST['user_image_id'];
$user_image = $_FILES['user_image']['name'];
$filePath = $_FILES['user_image']['tmp_name'];
$image = imagecreatefromstring(file_get_contents($_FILES['user_image']['tmp_name']));
$exif = exif_read_data($filePath);
if(!empty($exif['Orientation'])) {
switch($exif['Orientation']) {
case 8:
$image = imagerotate($image,90,0);
break;
case 3:
$image = imagerotate($image,180,0);
break;
case 6:
$image = imagerotate($image,-90,0);
break;
}
}
$image_target = $folder_target.basename($_FILES['user_image']['name']);
if(move_uploaded_file($_FILES['user_image']['tmp_name'], $image_target)){
if ($conn->query("UPDATE `users` SET `image`='$user_image' WHERE `id` LIKE '$upload_image_id'")){
echo 1;
}else{
echo "not update the name, Proplem";
}
}else{
echo 'image not uploaded';
}
}