1

I am trying to upload files (image ) in a directory I named "uploads" but it's yielding error each time I am clicking submit button . My codes are :

    <!DOCTYPE html>
    <html>
    <head>
    <title></title>
    </head>
    <body>

    <?php 

        $up_image=array(
                        "upload_image"=>"/"

                       );

        if (isset($_FILES['upload_image']))$up_image['upload_image']=$_FILES['upload_image'];

        $target_dir = "uploads/";
        $target_file = $target_dir . basename($_FILES["upload_image"]["name"]);

        if (isset($_POST['submit'])) {
            if (move_uploaded_file($_FILES["upload_image"]["tmp_name"], $target_file)) {
              echo "success !";
            }else{
                echo "error !";
            }
        }
    ?>
   <form action="upload.php" method="POST">
      <input type="file" name="upload_image">
      <input type="submit" name="submit">
   </form>
</body>
</html> 

the error I am getting is given bellow :

enter image description here

Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
Shishir
  • 187
  • 1
  • 8

0 Answers0