Advertisement
Guest User

Untitled

a guest
Jan 5th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. <html>
  2. <head>
  3. </head>
  4. <body>
  5. <form type="multipart/form-data">
  6. Select image to upload:
  7. <input type="file" name="fileToUpload" id="fileToUpload">
  8. <input type="submit" value="Upload Image" name="submit">
  9. </form>
  10. <?php
  11. session_start();
  12. $host="localhost";
  13. $username = "root";
  14. $password = "";
  15. $dbname = "image";
  16. $conn = mysqli_connect($host, $username, $password, $dbname);
  17. $target_dir = "uploads/";
  18. $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
  19. $uploadOk = 1;
  20. $imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
  21. // Check if image file is a actual image or fake image
  22. if(isset($_POST["submit"])) {
  23. $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
  24. if($check !== false) {
  25. echo "File is an image - " . $check["mime"] . ".";
  26. $uploadOk = 1;
  27. } else {
  28. echo "File is not an image.";
  29. $uploadOk = 0;
  30. }
  31. }
  32. ?>
  33. </body>
  34. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement