pastebin

Paste Search Dynamic
Recent pastes
Image upload script
  1. ?php
  2. $allowedExts = array("gif", "jpeg", "jpg");
  3. $temp = explode(".", $_FILES["file"]["name"]);
  4. echo $_FILES["file"]["size"];
  5. $extension = end($temp);
  6. if ((($_FILES["file"]["type"] == "image/gif")
  7. || ($_FILES["file"]["type"] == "image/jpeg")
  8. || ($_FILES["file"]["type"] == "image/jpg")
  9. || ($_FILES["file"]["type"] == "image/pjpeg")
  10. && ($_FILES["file"]["size"] < 204800)   // less 200kb
  11. && in_array($extension, $allowedExts))
  12. {
  13.     if ($_FILES["file"]["error"] > 0)
  14.     {
  15.         echo "错误:: " . $_FILES["file"]["error"] . "<br>";
  16.     }
  17.     else
  18.     {
  19.         echo "file name: " . $_FILES["file"]["name"] . "<br>";
  20.         echo "file type: " . $_FILES["file"]["type"] . "<br>";
  21.         echo "file size: " . ($_FILES["file"]["size"] / 1024) . " kB<br>";
  22.         echo "folder: " . $_FILES["file"]["tmp_name"] . "<br>";
  23.        
  24.         if (file_exists("uploads/" . $_FILES["file"]["name"]))
  25.         {
  26.             echo $_FILES["file"]["name"] . "File ";
  27.         }
  28.         else
  29.         {
  30.             /
  31.             move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]);
  32.             echo "文件存储在: " . "uploads/" . $_FILES["file"]["name"];
  33.         }
  34.     }
  35. }
  36. else
  37. {
  38.     echo "error";
  39. }
  40. ?>
Parsed in 0.040 seconds