Skip navigation
Currently Being Moderated

PHP upload problem

Apr 18, 2012 12:51 AM

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";

  }

?>

 
Replies

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points