Advertisement
Guest User

Upload

a guest
Apr 26th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.77 KB | None | 0 0
  1.  // image Upload File
  2.   $target_file = "uploads/" . basename($_FILES["image"]["name"]);
  3.   $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
  4.   $image = $_FILES['image']['name']; // The Thumbnail name
  5.   $image_tmp = $_FILES['image']['tmp_name']; // File in the PHP tmp folder
  6.  
  7.   if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" ) {
  8.     $error = 1;
  9.     }
  10.  
  11.   if (!$image_tmp) {
  12.     $error = 2;
  13.   }
  14.     // error's
  15.   if ($error == 1) {
  16.     $message = "Sorry, only JPG, JPEG & PNG files are allowed.</br>";
  17.   }
  18.  
  19.   if ($error == 2) {
  20.     $message = "You need to choose a Thumbnail for your project!";
  21.   }
  22.  
  23.     if ($_FILES["image"]["tmp_name"] == TRUE)
  24.     {
  25.     move_uploaded_file($_FILES["image"]["tmp_name"], $target_file);
  26.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement