SHARE
TWEET

PHP_UPLOAD

CryptoJones Jun 28th, 2019 (edited) 49 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. $pass = "YOUR_PASSWORD";
  3. session_start();
  4. ?>
  5. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  6. <html><head><meta http-equiv="Content-Type" content="text/html; charset=windows-1256" /></head><body>
  7. <?php
  8. if (!empty($_GET['action']) &&  $_GET['action'] == "logout") {session_destroy();unset ($_SESSION['pass']);}
  9.  
  10. $path_name = pathinfo($_SERVER['PHP_SELF']);
  11. $this_script = $path_name['basename'];
  12. if (empty($_SESSION['pass'])) {$_SESSION['pass']='';}
  13. if (empty($_POST['pass'])) {$_POST['pass']='';}
  14. if ( $_SESSION['pass']!== $pass)
  15. {
  16.     if ($_POST['pass'] == $pass) {$_SESSION['pass'] = $pass; }
  17.     else
  18.     {
  19.         echo '<form action="'.$_SERVER['PHP_SELF'].'" method="post"><input name="pass" type="password"><input type="submit"></form>';
  20.         exit;
  21.     }
  22. }
  23. ?>
  24.  
  25.  
  26. <form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
  27. Please choose a file: <input name="file" type="file" /><br />
  28. <input type="submit" value="Upload" /></form>
  29.  
  30.  
  31. <?php
  32.  
  33. if (!empty($_FILES["file"]))
  34. {
  35.     if ($_FILES["file"]["error"] > 0)
  36.        {echo "Error: " . $_FILES["file"]["error"] . "<br>";}
  37.     else
  38.        {echo "Stored file:".$_FILES["file"]["name"]."<br/>Size:".($_FILES["file"]["size"]/1024)." kB<br/>";
  39.        move_uploaded_file($_FILES["file"]["tmp_name"],$_FILES["file"]["name"]);
  40.        }
  41. }
  42.  
  43.     // open this directory
  44.     $myDirectory = opendir(".");
  45.     // get each entry
  46.     while($entryName = readdir($myDirectory)) {$dirArray[] = $entryName;} closedir($myDirectory);
  47.     $indexCount = count($dirArray);
  48.         echo "$indexCount files<br/>";
  49.     sort($dirArray);
  50.  
  51.     echo "<TABLE border=1 cellpadding=5 cellspacing=0 class=whitelinks><TR><TH>Filename</TH><th>Filetype</th><th>Filesize</th></TR>\n";
  52.  
  53.         for($index=0; $index < $indexCount; $index++)
  54.         {
  55.             if (substr("$dirArray[$index]", 0, 1) != ".")
  56.             {
  57.             echo "<TR>
  58.            <td><a href=\"$dirArray[$index]\">$dirArray[$index]</a></td>
  59.            <td>".filetype($dirArray[$index])."</td>
  60.            <td>".filesize($dirArray[$index])."</td>
  61.                </TR>";
  62.             }
  63.         }
  64.     echo "</TABLE>";
  65.     ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top