<!DOCTYPE html>
<html>
<head>
<title>Uploader Sederhana</title>
<style>
body { font-family: Arial; margin: 40px; }
.container { max-width: 400px; margin: auto; padding: 20px; border: 1px solid #ccc; border-radius: 8px; }
input[type="file"] { margin-bottom: 10px; }
</style>
</head>
<body>
<div class="container">
<h2>Upload File</h2>
<form method="POST" enctype="multipart/form-data">
<input type="file" name="file" required><br>
<button type="submit">Upload</button>
</form>
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['file'])) {
$targetDir = "uploads/";
if (!is_dir($targetDir)) {
mkdir($targetDir);
}
$fileName = basename($_FILES['file']['name']);
$targetFile = $targetDir . $fileName;
if (move_uploaded_file($_FILES['file']['tmp_name'], $targetFile)) {
echo "<p>File berhasil diupload: <strong>" . htmlspecialchars($fileName) . "</strong></p>";
} else {
echo "<p>Gagal mengupload file.</p>";
}
}
?>
</div>
</body>
</html>