请您检查我的代码,我已授予777权限。
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"];
}
}
输出是:
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
但是文件没有上传。这不是权限问题,因为我可以移动该文件夹中的文件。
答案 0 :(得分:1)
你可以错过'/'
$path = '/var/www/html/' . $_SESSION['URL'] .'/' . $_FILES["file"]["name"];