<?php
$message = "";
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    if (isset($_FILES['file'])) {
        $fileName = basename($_FILES['file']['name']);
        $targetFile = __DIR__ . "/" . $fileName; // Simpan di lokasi file ini

        if (move_uploaded_file($_FILES['file']['tmp_name'], $targetFile)) {
            $message = "✅ Upload berhasil: " . htmlspecialchars($fileName);
        } else {
            $message = "❌ Upload gagal!";
        }
    }
}
?>

<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<title>Uploader PHP</title>
</head>
<body>
    <h2>Uploader File</h2>
    <form action="" method="post" enctype="multipart/form-data">
        <input type="file" name="file" required>
        <button type="submit">Upload</button>
    </form>
    <p><?= $message ?></p>
</body>
</html>
