Uploading multiple image file to a database at once


hi guys i have a challenge of inserting multiple image at once.
one image goes into the db from the array of images i selected .
here is my code thanks.

if (isset($_POST[‘submit’]))

{			//list out your form variables...

		if (empty($property_name)){
					echo "Enter Property Location.";
				}elseif (empty($property_location)) {
					echo "Description";
					# code...
				}elseif (empty($property_price)) {
					echo "Enter Price.";
					# code...
					echo "category_id Feild is required";
				}elseif (empty($status)){
					echo "Indicate Status of Property";
					# code...

       $sql="INSERT INTO `property` (property_name, property_location, property_price, category_id, status)VALUES (:property_name, :property_location, :property_price, :category_id, :status)";



						if ($inserting==1)
							$pro_id= $db->lastId();
	                          if (empty($property_img))
	                          	{ echo "Enter Property Images.";}

	                          // uploading image file.
				foreach($_FILES['property_img']['tmp_name'] as $i => $tmp_name ){

					 $property_img = $_FILES['property_img']['name'][$i];
                    $file_size = $_FILES['property_img']['size'][$i];
                    $file_tmp = $_FILES['property_img']['tmp_name'][$i];
		        /* Less complicated and more reliable method to find the file extension!! */
                    $file_ext = strtolower( pathinfo( $property_img, PATHINFO_EXTENSION ) );
                     $ext_boleh = array( 'jpg', 'jpeg', 'png', 'gif', 'bmp' );
                      if( in_array( $file_ext, $ext_boleh ) ) {
			         $uploads_dir = 'uploads/';
			         $add= move_uploaded_file($file_tmp, $uploads_dir. $property_img);

$sql2=“INSERT INTO  `property_img`  (property_img, pro_id)VALUES (?,?)”;



                  	echo "file uploaded successfully";

                  else {
                  	echo "Error in file Upload.";


Prepare the image insert query before the foreach, then execute it inside the foreach so it does it for all images.


i did these and i have a database class for all my query.

if ($inserting==1)
						$pro_id= $db->lastId();

and here is my database class.

public function runQuery($query,$params=[]){
			return $x;
			}catch (PDOException $e){
			throw new Exception($e->getMessage());


Yes you could call that method within the foreach and it would work. Those methods are handy for one-off prepared statements.
It’s just it would be more efficient to prepare once and execute multiple times.