<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    if (isset($_FILES['file'])) {
        echo '<pre>';
        print_r($_FILES['file']);
        echo '</pre>';

        if ($_FILES['file']['error'] === UPLOAD_ERR_OK) {
            echo "Upload berhasil!<br>";
            echo "Tmp name: " . $_FILES['file']['tmp_name'] . "<br>";
        } else {
            echo "Error saat upload: " . $_FILES['file']['error'] . "<br>";
        }
    } else {
        echo "File tidak ditemukan di \$_FILES.";
    }
    exit;
}
?>

<form method="POST" enctype="multipart/form-data">
    Pilih file: <input type="file" name="file" />
    <button type="submit">Upload</button>
</form>
