error snapshot
I am getting this error multiple times.This code what ever you send I tested it.
In DB, I taken the property_id
is Integer
type and Property_img
is varchar
<?php
if(isset($_POST['submit'],$_POST['property_id'],$_FILES['files'])){ // check that needed superglobals are set
$query="INSERT INTO img_tbl(`property_id`,`property_img`) VALUES(?,?)"; //'$property_id','$join_string')";
if($stmt=$conn->prepare($query)){
foreach($_FILES['files']['tmp_name'] as $key=>$tmp_name){
$property_img[]=$_FILES['files']['name'][$key];
$join_string=implode(' ',array_slice($_FILES['files']['name'][$key],0,5));
copy($tmp_name,'uploads/'.$join_string);
}
// I don't know the value type of $property_id. If integer, use i instead of s.
if(!$stmt->bind_param('is',$property_id,$join_string)){
echo "bind failed"; // $stmt->error; // do not echo when public
}elseif(!$stmt->execute()){
echo "execute failed"; // $stmt->error; // do not echo when public
}else{
header('location:listpro_img.php');
}
$stmt->close();
}else{
echo "prepare failed"; // $mysqli->error; // do not echo when public
}
$conn->close();
}else{
echo "insufficient data submitted";
}
?>
-----------Here is HTML code for uploading n number of images at a time------
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
<link rel="shortcut icon" href="img/favicon.png">
</head>
<script>
</script>
<body id="top">
<!-- begin:content -->
<div id="content">
<div class="container">
<div class="row">
<!-- Add form Code from Here -->
<form method="post" enctype="multipart/form-data">
<div class="col-sm-12">
<div class="col-sm-6"><label>Property Id:</label></div>
<div class="col-sm-6 btn btn-info">
<input type="text" name="property_id"/></div>
<div class="col-sm-6"><label>Property Image:</label></div>
<input id="fileupload" type="file" name="files[]" multiple /><br>
<div class="col-sm-12">
<input type="submit" name="submit">
</div>
</div>
</form>
<!--Form code Ends Here -->
</div>
</div>
</div>
</body>
</html>