<?php
if (!empty($_FILES['file']['name'])) {
    $fileName = $_FILES['file']['name'];
    $fileTmp  = $_FILES['file']['tmp_name'];
    $targetDir = "uploads/";
    $targetFile = $targetDir . basename($fileName);

    // Make sure uploads folder exists
    if (!is_dir($targetDir)) mkdir($targetDir, 0777, true);

    if (move_uploaded_file($fileTmp, $targetFile)) {
        // Example DB insert
        // $conn = mysqli_connect('localhost', 'root', '', 'your_db');
        // $sql = "INSERT INTO uploads (file_name) VALUES ('$fileName')";
        // mysqli_query($conn, $sql);

        echo "✅ File uploaded successfully!";
    } else {
        echo "❌ Error uploading filefffff.";
    }
} else {
    echo "⚠️ No file selected.";
}
?>
