<?php
include "../database/database.php";



if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_FILES["image"])) {
    $image = $_FILES["image"]["tmp_name"];
    $imgContent = addslashes(file_get_contents($image));


    // Insert image content into database
    $sql = "INSERT INTO images (image) VALUES ('$imgContent')";

    if ($connection->query($sql) === TRUE) {
        echo "Image uploaded successfully.";
    } else {
        echo "Error: " . $sql . "<br>" . $connection->error;
    }

    $connection->close();
} else {
    echo "Please select an image to upload.";
}
?>

