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 ''; } ?>

New Perspectives on HTML5, CSS3, and JavaScript
6th Edition
ISBN:9781305503922
Author:Patrick M. Carey
Publisher:Patrick M. Carey
Chapter6: Working With Tables And Columns: Creating A Program Schedule For A Radio Station
Section: Chapter Questions
Problem 8CP2
icon
Related questions
Question

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'; ?>

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Form and its Elements
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
New Perspectives on HTML5, CSS3, and JavaScript
New Perspectives on HTML5, CSS3, and JavaScript
Computer Science
ISBN:
9781305503922
Author:
Patrick M. Carey
Publisher:
Cengage Learning