4 Replies Latest reply: Apr 18, 2012 6:50 AM by manojb05 RSS

    PHP upload problem

    manojb05 Community Member

      Dear All,

      I am try to upload some image but some error come in PHP

      please help this

       

      Upload: 7890.jpg

      Type: image/jpeg

      Size: 0 Kb

      Temp file: /tmp/phpxHoiiQ

       

      Warning: move_uploaded_file(upload/7890.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in /home/newtoncli/domains/newtonclients.com/public_html/upload_file.php on line 25

       

      Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpxHoiiQ' to 'upload/7890.jpg' in /home/newtoncli/domains/newtonclients.com/public_html/upload_file.php on line 25

      Stored in: upload/7890.jpg

       

      CODE

      <html>

      <body>

       

       

      <form action="upload_file.php" method="post"

      enctype="multipart/form-data">

      <label for="file">Filename:</label>

      <input type="file" name="file" id="file" />

      <br />

      <input type="submit" name="submit" value="Submit" />

      </form>

       

       

      </body>

      </html>

       

      PHP

      <?php

      if ((($_FILES["file"]["type"] == "image/gif")

      || ($_FILES["file"]["type"] == "image/jpeg")

      || ($_FILES["file"]["type"] == "image/pjpeg"))

      && ($_FILES["file"]["size"] < 20000))

        {

        if ($_FILES["file"]["error"] > 0)

          {

          echo "Return Code: " . $_FILES["file"]["error"] . "<br />";

          }

        else

          {

          echo "Upload: " . $_FILES["file"]["name"] . "<br />";

          echo "Type: " . $_FILES["file"]["type"] . "<br />";

          echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";

          echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";

       

       

          if (file_exists("upload/" . $_FILES["file"]["name"]))

            {

            echo $_FILES["file"]["name"] . " already exists. ";

            }

          else

            {

            move_uploaded_file($_FILES["file"]["tmp_name"],

            "upload/" . $_FILES["file"]["name"]);

            echo "Stored in: " . "upload/" . $_FILES["file"]["name"];

            }

          }

        }

      else

        {

        echo "Invalid file";

        }

      ?>