Guest User

Untitled

a guest
Apr 26th, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 KB | None | 0 0
  1. if(!empty($_FILES)){
  2. $photo1 = $_FILES['photo1'];
  3. $photo2 = $_FILES['photo2'];
  4. $photo3 = $_FILES['photo3'];
  5. $photo4 = $_FILES['photo4'];
  6. $photo5 = $_FILES['photo5'];
  7. $photo6 = $_FILES['photo6'];
  8. $photo7 = $_FILES['photo7'];
  9. $photo = [$photo1,$photo2,$photo3,$photo4,$photo5,$photo6,$photo7];
  10. foreach ($photo as $photos) {
  11. $name = $photos['name'];
  12. $nameArray = explode('.',$name);
  13. $filename = $nameArray[0];
  14. $fileEXT = $nameArray[1];
  15. $mime = explode('/', $photos['type']);
  16. $mimeType = $mime[0];
  17. $mimeEXT = $mime[1];
  18. $temploc = $photos['tmp_name'];
  19. $filesize = $photos['size'];
  20. $allowed = array('png','jpg','jpeg','gif',);
  21. $uploadname = md5(microtime()).'.'.$fileEXT;
  22. $uploadpath = LINKURL.'/imgs/photos/'.$uploadname;
  23. $dbpath = '/realeastate/imgs/photos/'.$uploadname;
  24. if($mimeType != 'image'){
  25. $errors[]= 'File must be an image';
  26. }
  27. if(!in_array(strtolower($fileEXT), $allowed)){
  28. $errors[]= 'The photo extension must be jpg,png,jpeg or gif.';
  29. }
  30. if($filesize > 25000000){
  31. $errors[]= 'The file size must be less than 25MB.';
  32. }
  33. if(strtolower($fileEXT) != $mimeEXT && $mimeEXT == 'jpeg' && strtolower($fileEXT) != 'jpg' ){
  34. $errors[]= 'File extension does not match the file.';
  35. }
  36.  
  37. if(!empty($errors)){
  38. echo show_errors($errors);
  39. } else {
  40. //upload file and insert into database
  41. if (!empty($_FILES)) {
  42. move_uploaded_file($temploc,$uploadpath);
  43. }
  44. if(isset($_GET['edit'])){
  45. $db->query("UPDATE property SET taken ='$taken' WHERE id ='$edit_id'");
  46. }else{
  47. $db->query("INSERT INTO property (category,status,purpose,cover,images,city,place,price,payment,garage,wideness,visit,takenhome,hospital,school,market,bank,church,mosque,government,datetostart,floor) VALUES ('$category','$status','$purpose','$dbpath','$city','$place','$price','$payment','$garage','$wide','$dprice','$adprice','$hospital','$school','$church','$mosque','$government','$opendate','$floor')");
  48. }
  49.  
  50. }
  51.  
  52. }
  53.  
  54. $_SESSION['success'] = 'Property Added successful';
  55. header('Location: house.php');
  56.  
  57.  
  58. }
Add Comment
Please, Sign In to add comment