0

Would you check my code please, I have given 777 permissions.

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 />";
$path = 'var/www/html/' . $_SESSION['URL'] .'/' . $_FILES["file"]["name"];
if (file_exists('var/www/html/' . $_SESSION['URL'] .'/'. $_FILES["file"]["name"]))
  {
  echo $_FILES["file"]["name"] . " already exists. ";
  }
else
  {
 move_uploaded_file($_FILES["file"]["tmp_name"], $path);

  echo "Stored in: " . 'var/www/html/' . $_SESSION['URL'] .'/' . $_FILES["file"]["name"];
  }
}

Output is:

Upload: lamp.odt
Type: application/vnd.oasis.opendocument.text
Size: 57.5595703125 Kb
Temp file: /tmp/phpuch5Kp
path is var/www/html/man/lamp.odtStored in: var/www/html/man/lamp.odt

But file is not getting uploaded. It's not permission issue as I can move files in that folder.

3
  • You can see the temp file, but does it contain any data? You said the file isn't getting uploaded... Do you mean that no data is sent, or that you can't get to its data via $_FILES? Commented Sep 28, 2014 at 6:36
  • where to find tmp file? My OUTPUT SAys "Temp file: /tmp/phpuch5Kp" But there is no such file in folder TMP File is not getting upladed means , when I check the desired folder it is empty, no file is moved to it. Commented Sep 28, 2014 at 7:07
  • fixed '/' was missing, Thanks for help guys :-) Commented Sep 28, 2014 at 7:17

1 Answer 1

1

you can miss '/'

$path = '/var/www/html/' . $_SESSION['URL'] .'/' . $_FILES["file"]["name"];
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.