-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
34 lines (26 loc) · 872 Bytes
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_FILES["file"])) {
$uploadDir = "uploads/";
$targetFile = $uploadDir . basename($_FILES["file"]["name"]);
if (move_uploaded_file($_FILES["file"]["tmp_name"], $targetFile)) {
echo "File berhasil diunggah.";
} else {
echo "Maaf, ada masalah saat mengunggah file.";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Unggah File</title>
</head>
<body>
<h2>Unggah File</h2>
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="post" enctype="multipart/form-data">
<input type="file" name="file" id="file">
<button type="submit" name="submit">Unggah</button>
</form>
</body>
</html>