i can not find the error in my code to move the image to the folder the folder is in the same location as the codes files details of the post: select image prepare("insert into post(productName,productDetails,image,name) values(?,?,?,?)"); $st->bind_param("ssss", $_POST["pn"], $_POST["pd"],$_POST["image"],$_SESSION["name"]); $st->execute(); echo ''; } ?>
i can not find the error in my code to move the image to the folder
the folder is in the same location as the codes files
<?php include 'header.php'; ?>
<div class=" container-fluid" style="background-color: #F4F9FF">
<div class="inner text-center">
<form action="provider.php" method="post" >
<h3>details of the post:</h3>
<div class="form-wrapper " style="width:180% " >
<input type="text" placeholder="product name" class="form-control" name="pn" required />
</div>
<div class="form-wrapper" style="width:180% ">
<input type="text" name="pd" placeholder="product details.." style="height:150px; width: 100%"/>
<i class="zmdi zmdi-comment"></i>
</div>
<br>
<div class="form-wrapper" style="width:40% ">
<label><p style=" text-indent: 50px; text-align: justify;letter-spacing: 3px;">select image</p></label>
<input type="file" name="image" accept="image/*" />
</div>
<br>
<input type="submit" name="sub" value="SAVE" class="zmdi zmdi-arrow-right form-control" />
</form>
</div>
</div>
<?php
if(isset($_POST["sub"]))
{
move_uploaded_file($_FILES["image"]["tmp_name"], "img/" . $_FILES["image"]["name"]);
$con = new mysqli("localhost", "root","", "voluntary");
$st = $con->prepare("insert into post(productName,productDetails,image,name) values(?,?,?,?)");
$st->bind_param("ssss", $_POST["pn"], $_POST["pd"],$_POST["image"],$_SESSION["name"]);
$st->execute();
echo '<script> window.location = "Provider.php"; </script>';
}
?>
<?php include 'footer.php'; ?>
Step by step
Solved in 2 steps