Advertisement
Guest User

Untitled

a guest
Dec 11th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. $listingId = $_GET['listing_id'];
  2.  
  3. if(isset($_POST['submit']))
  4. {
  5. $target_dir = "./images/listing_images/";
  6. $target_file = $target_dir . basename($_FILES["file_selected"]["name"]);
  7.  
  8. //temp varriables for file details
  9. $file_name = $_FILES["file_selected"]["name"];
  10. $file_type = strtolower(pathinfo($target_file, PATHINFO_EXTENSION));
  11. $file_size = $_FILES["file_selected"]["size"];
  12. $is_valid = 1;
  13.  
  14. if($file_type != "jpg")
  15. {
  16. $is_valid = 0;
  17. echo "File must be a jpg!";
  18. }
  19. if($file_size > MAX_FILE_SIZE)
  20. {
  21. $is_valid = 0;
  22. echo "File cannot be larger than " + MAX_FILE_SIZE;
  23. }
  24. if ($is_valid == 1)
  25. {
  26. move_uploaded_file($_FILES["file_selected"]["tmp_name"], $target_file);
  27.  
  28. echo "Success!";
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement