Warning: move_uploaded_file(activities.png):
failed to open stream:
Permission denied in /var/www/vhosts/default/htdocs/backoffice/db/changelogo.php on line 17
Warning: move_uploaded_file():
Unable to move '/tmp/phpTNQXEi' to 'activities.png' in /var/www/vhosts/default/htdocs/backoffice/db/changelogo.php on line 17
因此,由于此 .php 脚本的文件权限不正确,我被拒绝了权限。
如何允许文件上传而不是获得使用 SSH(或 SFTP)拒绝的权限来获得允许图像上传的权限。
这是供参考的php脚本:
<?php
include 'realtydevkit.php';
session_start();
umask(0077);
$name = $_FILES['yourlogo']['name'];
$tmpname = $_FILES['yourlogo']['tmp_name'];
$error = $_FILES['yourlogo']['error'];
ini_set("display_errors", 1);
echo $error;
if ($name) {
$directory = $name;
$userid = $_SESSION['userid'];
$type = "logo";
$file = move_uploaded_file($tmpname, $directory);
if ($file) {
mysql_query("INSERT INTO usercontent
(`userid`, `type`, `url`) VALUES
('$userid', '$type', '$directory')");
echo 'Uploaded';
echo "<img src='".$directory."'/>";
} else {
echo 'There was an error moving the file.';
}
chmod($directory, 0644);
}
?>