Jump to content

Multiple file upload not working.


briansykes

Recommended Posts

Hello everyone i am trying to make a multiple file upload script and its not going well instead of moving the files it doesn't and then continuously adds rows to a myself DB table.  the code is below.

 

$query = mysql_query("INSERT INTO `listings` (state,name,location,price,typeofhome,bathrooms,bedrooms,basement,garage,features,remarks,lotsize,mlsid,hot) VALUES ('$status','$_POST[title]','$_POST[location]','$_POST[price]','$_POST[typeofhome]','$_POST[bathrooms]','$_POST[bedrooms]','$_POST[basment]','$_POST[garage]','$_POST[features]','$_POST[remarks]','$_POST[lot]','$_POST[mls]','$ishot')") or die("Failed because of ".mysql_error());
                        if ($query==TRUE) {
	               $id = mysql_insert_id();
			$tmp = md5(rand());
			mkdir("pics/$tmp");
			$upload_dir = "pics/$tmp/";
			chmod($upload_dir,0777);
			mysql_query("UPDATE `listings` SET `imgloco` = '$upload_dir' WHERE `id` = '$id'");
			$num = $_POST['picnum'];
			$i = 1;
			while ($i>=$num) {
				echo "hi";
				$file_tmp = $_FILES['pic'.$i]['tmp_name'];
				$file_name = $_FILES['pic'.$i]['name'];
				$loco = $upload_dir.$file_name;
				move_uploaded_file($file_tmp,$loco);
				mysql_query("INSERT INTO `list_images` (lid,location) VALUES ('$id','$loco')");
				$i++;
			}
                                redirect("templates/dellisting.php");
                        } else {
                                redirect("templates/addlisting.php");
                        }

Link to comment
https://forums.phpfreaks.com/topic/116511-multiple-file-upload-not-working/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.