<?php
if (isset($_POST['submit']) {
$tmpfile = $_FILES['fileupload']['tmp_name'];
$newfile = "uploads/".time().$_FILES['fileupload']['name'];
if(move_uploaded_file($tmpfile, $newfile)) {
echo "Upload file sukses";
} else {
echo "Upload file gagal";
}
}
?>
<!DOCTYPE html>
<html lang="id">
<head><title>Mekanisme Upload File</title></head>
<body>
<h2>Mekanisme Upload File</h2>
<form action="<?= $_SERVER['PHP_SELF']; ?>" method="post"
enctype="multipart/form-data">
<label for="thefile">
File (maksimum <?= ini_get('post_max_size') ?>B) :</label>
<input type="file" id="thefile" name="fileupload">
<input type="submit" name="submit" value="Upload">
</form>
</body>
</html>
Comments