If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 2 of 2
  1. #1
    Junior Member
    Join Date
    Mar 2018
    Member #

    Uploading multiple images for one real estate property

    Hi folks, I am using a free script I downloaded to list real estate properties online. I would like each property to have as many photos as practicable. Problem is only one images (the last one) gets uploaded. I would appreciate it very much if somebody can look at the code and help me out. Thank you all in advance.

    HTML Code:
    $mess_err = '';
    		$mess_err .="+ ".$messhousename."<br />";
    	else if(strlen($_POST['txtName'])<6){
    		$mess_err .= "+ ".$messlenHN."<br />";
    		else $mess_err .= '';
    		$mess_err .= "+ ".$messcity."<br/>";
    	else if(intval($_POST['selectDistrict'])==0){
    		$mess_err .= "+ ".$messdistrict."<br/>";
    		$mess_err .= "+ ".$messaddress."<br/>";
    	else if(strlen($_POST['txtAddress'])<6){
    		$mess_err .= "+".$messlenaddress."<br/>";
    		$mess_err .= "+ ".$messlivingsize."<br/>";
    		$mess_err .= "+ ".$messcaptcha."<br>";
    	else if($_POST['captcha'] != $_SESSION["security_code"]){
    		$mess_err .= "+ ".$messincorrectcaptcha;
    		if ( (($imgtype == "image/gif")|| ($imgtype == "image/jpeg")|| ($imgtype == "image/jpg")|| ($imgtype == "image/pjpeg")|| ($imgtype == "image/png")))
    			if ($_FILES["imageFile"]["error"] > 0)
    				$mess_err .= "+ ".$imageinvalid."<br>";
    				if($imgsize>1400000) $mess_err .="+ ".$sizeimage."<br />";
    		else $mess_err .= "+ ".$imageinvalid."<br />";
    if(!isset($mess_err))$mess_err=" ";
    if(!isset($mess_success)) $mess_success=" ";
    if(empty($mess_err)&& isset($_POST['sbAddHouse']))
    			if(!isset($_POST['chkIncludeTax']))$_POST['chkIncludeTax'] =0;
    			if(!isset($_POST['chkCooling']))$_POST['chkCooling'] =0;
    			if(!isset($_POST['chkLaundry']))$_POST['chkLaundry'] =0;
    			if(!isset($_POST['chkSwimming']))$_POST['chkSwimming'] =0;
    			if(!isset($_POST['chkGarden']))$_POST['chkGarden'] =0;
    			if(!isset($_POST['chkYard']))$_POST['chkYard'] =0;
    			if(!isset($_POST['chkHeating']))$_POST['chkHeating'] =0;
                $query = "insert into houses(city_id, district_id, category_id, user_id, need_id, legal_id, direction_id, name, address, yearbuilt, description, created, lotsize, livingsize, price, includetax, mls, amentities, stories, floorcoverings, rooftype, bathroom, diningroom, bedroom, kitchen, livingroom, miscrooms, heating, cooling, water, sewer, laundry, parking, swimmingpool, garden, yardgrounds, handicapfeatures, status, views, contactname, contactemail, contactphone, contactmobile,latitude,longitude,fulladdress,unit) values(".intval($_POST['selectTinhTP']).", ".intval($_POST['selectDistrict']).",".intval($_POST['selectCate']).",".intval(0).", ".$_POST['selectNeed'].", ".$_POST['selectLegal'].", ".$_POST['selectDirection'].", '".mysql_real_escape_string($_POST['txtName'])."', '".mysql_real_escape_string($_POST['txtAddress'])."', '".mysql_real_escape_string($_POST['txtYearBuilt'])."', '".$Description."','".$now1."', ".intval($_POST['txtLotsize']).", ".$_POST['txtLivingsize'].", ".floatval($_POST['txtnewprice']).", ".$_POST['chkIncludeTax'].", '".mysql_real_escape_string($_POST['txtMLS'])."', '".$Amenity."', ".intval($_POST['txtNumBlock']).", '".mysql_real_escape_string($_POST['txtFloorCovering'])."', '".mysql_real_escape_string($_POST['txtRoofType'])."', ".intval($_POST['txtBathRoom']).", ".intval($_POST['txtDiningRoom']).", ".intval($_POST['txtBedRoom']).", ".intval($_POST['txtKitchen']).", ".intval($_POST['txtLivingRoom']).", '".intval($_POST['txtMiscRoom'])."','".intval($_POST['chkHeating'])."', ".intval($_POST['chkCooling']).", 0, 0, ".intval($_POST['chkLaundry']).", '".intval($_POST['txtParking'])."', ".intval($_POST['chkSwimming']).", ".intval($_POST['chkGarden']).", ".intval($_POST['chkYard']).", '', 0, 0, '".mysql_real_escape_string($_POST['fullname'])."', '".mysql_real_escape_string($_POST['txtemail'])."', '".mysql_real_escape_string($_POST['txtphone'])."', '".mysql_real_escape_string($_POST['txtmobile'])."','".mysql_real_escape_string($_POST['lat'])."','".mysql_real_escape_string($_POST['lng'])."','".mysql_real_escape_string($_POST['newaddress'])."','".$_POST['selectTime']."')";
                            if(QuerySQL($query)) {$mess_err="+ ".$postnewssuc;}
    						else {echo "Error insert";$mess_success="";}
    							$length = 8;					
    							$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    							$rndstr = '';	
    							for ($p = 0; $p < $length; $p++) {
    								$rndstr .= $characters[mt_rand(0, strlen($characters))];
    							$newImagename=md5(date('m/d/Y h:i:s').$rndstr).".".$newimgtype;
    							$newimage = new SimpleImage();
    							$newimage->save("uploads/" .$newImagename);
    							$sql ="INSERT INTO `imgs` (`house_id` ,`name`,`mainimg`,status)	VALUES (".mysql_insert_id().",'$newImagename',1,0)";			
    										$rs = QuerySQL($sql);
    <form action="<?php $_SERVER['PHP_SELF']; ?>" method="post" name="formAddHouse"onsubmit="return checkFormAddHouse();" enctype="multipart/form-data">
    <input type="file" name="imageFile" id="imageFile" />
    <input type="file" name="imageFile" id="imageFile" />
    <input type="file" name="imageFile" id="imageFile" />
    <input type="submit" value="<?php echo strtoupper($addhouse);?>" id="sbAddHouse" name="sbAddHouse" style="width:100px;" onclick="window.location.href='#here';" >


  3. #2
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Cottage Grove, Minnesota
    Member #
    725 times
    That's a really old out-dated script. I'm super surprised it works on your webhost since MySQL has been obsolete for a while now. They must be running old PHP versions (which is also a bad thing). Your script will not execute on my website.

    You should find a new PHP / PDO upload script. But you would have to customize it to upload the other information as well, and do the photo resizing.

    To answer your question, you will have to create an array of photos, and then process the array.

    Like this:

    PHP Code:
            <form method='post' action='' enctype='multipart/form-data'>
    input type='file' name='imageFile[]' id='imageFile' multiple />
    input type='submit' value='Submit' name='submit' />
    Notice the [ ] square brackets with the name of your file tag.
    That signifies an array of photos.

    But it's not done yet ...

    Then you have to loop through the array to process each photo.
    That will require a rewrite of your PHP script ... which I don't have time to describe and no way to test it.

    Here's a place to see how it's done:
    Upload Multiple Image files to the Database using PDO ? PHP

    If you download the 'demo' scripts, you can see the actual PHP coding.

    Your existing script is obsolete and therefore has security issues, along with your webhost PHP version that allows you to use MySQL. I would not even be willing to make it work for you. That would not be ethical.

    Here is a modern PHP / PDO real estate script for only $21:
    Last edited by mlseim; Mar 12th, 2018 at 04:11 PM.

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Tags for this Thread

All times are GMT -6. The time now is 06:55 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2020 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: