Server : LiteSpeed System : Linux in-mum-web1949.main-hosting.eu 5.14.0-503.40.1.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Mon May 5 06:06:04 EDT 2025 x86_64 User : u595547767 ( 595547767) PHP Version : 7.4.33 Disable Function : NONE Directory : /home/u595547767/domains/nilasevasamithi.com/public_html/admin/ |
<?php
//update.php
include('connect.php');
if (isset($_POST['image_id'])) {
$image_id = $_POST['image_id'];
if (!empty($_FILES['file_name']['name'])) {
$fileTmp = $_FILES['file_name']['tmp_name'];
$allowImg = array('png','jpeg','jpg','gif');
$fileExnt = explode('.', $_FILES['file_name']['name']);
$fileActExt = strtolower(end($fileExnt));
$newFile = rand(). '.'. $fileActExt;
$destination = 'uploads/hotels/'.$newFile;
if (in_array($fileActExt, $allowImg)) {
if ($_FILES['file_name']['size'] > 0 && $_FILES['file_name']['error']==0) {
$query = "SELECT * FROM tbl_hotelimages WHERE himg_id = '$image_id'";
$result = mysqli_query($con, $query);
$row = mysqli_fetch_assoc($result);
$filePath = 'uploads/hotels/'.$row['hotel_img'];
if (move_uploaded_file($fileTmp, $destination)) {
$update = "UPDATE tbl_hotelimages SET hotel_img = '$newFile' WHERE himg_id = '$image_id'";
mysqli_query($con, $update);
unlink($filePath);
}
}
}
}
}
//placesimages update
if (isset($_POST['image_id1'])) {
$image_id = $_POST['image_id1'];
if (!empty($_FILES['file_name']['name'])) {
$fileTmp = $_FILES['file_name']['tmp_name'];
$allowImg = array('png','jpeg','jpg','gif');
$fileExnt = explode('.', $_FILES['file_name']['name']);
$fileActExt = strtolower(end($fileExnt));
$newFile = rand(). '.'. $fileActExt;
$destination = 'uploads/places/'.$newFile;
if (in_array($fileActExt, $allowImg)) {
if ($_FILES['file_name']['size'] > 0 && $_FILES['file_name']['error']==0) {
$query = "SELECT * FROM tbl_placesimages WHERE img_id = '$image_id'";
$result = mysqli_query($con, $query);
$row = mysqli_fetch_assoc($result);
$filePath = 'uploads/places/'.$row['file_name'];
if (move_uploaded_file($fileTmp, $destination)) {
$update = "UPDATE tbl_placesimages SET file_name = '$newFile' WHERE img_id = '$image_id'";
mysqli_query($con, $update);
unlink($filePath);
}
}
}
}
}
?>