gurumutant

Upload file menggunakan PHP tanpa validasi

May 2nd, 2018
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.70 KB | None | 0 0
  1. <?php
  2. if (isset($_POST['submit']) {
  3.     $tmpfile = $_FILES['fileupload']['tmp_name'];
  4.     $newfile = "uploads/".time().$_FILES['fileupload']['name'];
  5.     if(move_uploaded_file($tmpfile, $newfile)) {
  6.         echo "Upload file sukses";
  7.     } else {
  8.         echo "Upload file gagal";
  9.     }
  10. }
  11. ?>
  12. <!DOCTYPE html>
  13. <html lang="id">
  14. <head><title>Mekanisme Upload File</title></head>
  15. <body>
  16.     <h2>Mekanisme Upload File</h2>
  17.     <form action="<?= $_SERVER['PHP_SELF']; ?>" method="post"
  18.         enctype="multipart/form-data">
  19.         <label for="thefile">
  20.         File (maksimum <?= ini_get('post_max_size') ?>B) :</label>
  21.         <input type="file" id="thefile" name="fileupload">
  22.         <input type="submit" name="submit" value="Upload">
  23.     </form>
  24. </body>
  25. </html>
Add Comment
Please, Sign In to add comment