Advertisement
Guest User

Untitled

a guest
Sep 30th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. <form action="upload.php" method="post" enctype="multipart/form-data">
  2. Select image to upload:
  3. <input type="file" name="fileToUpload" id="fileToUpload">
  4. <input type="submit" value="Upload Image" name="submit">
  5.  
  6. <?php
  7. $target_dir = "uploads/";
  8. $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
  9. $uploadOk = 1;
  10. $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
  11. // Check if image file is a actual image or fake image
  12. if(isset($_POST["submit"])) {
  13. $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
  14. if($check !== false) {
  15. echo "File is an image - " . $check["mime"] . ".";
  16. $uploadOk = 1;
  17. } else {
  18. echo "File is not an image.";
  19. $uploadOk = 0;
  20. }
  21. }
  22. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement