Advertisement
Guest User

Untitled

a guest
Apr 20th, 2017
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. <?php
  2. $conn = new PDO ("mysql:host=localhost;dbname=project;", "root", "0612733771Aa");
  3.  
  4. if(!isset($_FILES['upload']) || $_FILES['upload']['error'] == UPLOAD_ERR_NO_FILE) {
  5. echo "Error no file selected";
  6. } else {
  7.  
  8. if (isset($_POST["submit"]) && isset($_FILES['upload'])) {
  9. $image_size = getimagesize($_FILES['upload']['tmp_name']);
  10. if ($image_size === FALSE) {
  11. die("Unable to determine image type of uploaded file");
  12. }
  13.  
  14. if (($image_size[2] !== IMAGETYPE_GIF) && ($image_size[2] !== IMAGETYPE_JPEG) && ($image_size[2] !== IMAGETYPE_PNG)) {
  15. die("Not a gif/jpeg/png");
  16. }
  17. }
  18. else {
  19. print "File was not uploaded succesfully";
  20. exit;
  21. }
  22. $image = $_FILES['upload']['tmp_name'];
  23. $title = $_POST['title'];
  24. $description = $_POST['description'];
  25. $category = $_POST['category'];
  26.  
  27. if ($image_size === FALSE)
  28. echo "That isn't an image!";
  29. else {
  30. $conn->query = ("INSERT INTO images (title, description, image, category) VALUES ('$title', '$description', '$image', '$category')");
  31. }
  32. }
  33. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement