Advertisement
Guest User

upload.php Form Handling

a guest
Jul 30th, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.75 KB | None | 0 0
  1. <?php
  2. include("index.html");
  3. if(!empty($_POST)) {
  4.     if(isset($_FILES["world"])) {
  5.        
  6.         $world = $_FILES["world"];
  7.        
  8.         $name = $world["name"];
  9.         $tmp_name = $world["tmp_name"];
  10.         $size = $world["size"];
  11.         $ext = explode('.', $name);
  12.         $ext = strtolower(end($ext));
  13.        
  14.         $allowed = "deep";
  15.        
  16.         if ($ext == $allowed) {
  17.             if ($size <= 300000) {
  18.                 $id = uniqid('', true);
  19.                 $destination = 'worlds/' . $id . '.' . $ext;
  20.                 if(move_uploaded_file($tmp_name, $destination)) {
  21.                     echo '<br/>World: "' . $name . '" uploaded to DeeperNet!';
  22.                     echo<br/>World ID:. $id;
  23.                     $info = fopen('worlds/' . $id . '.txt', 'w');
  24.                     fwrite($info, $_POST['name'] . "\r\n");
  25.                     fwrite($info, $_POST['desc']);
  26.                     fclose($info);
  27.                 }
  28.             }
  29.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement