我已尝试搜索但无法找到问题的答案 - 我正在尝试上传图片并收到以下错误。
这是我的错误日志:
PHP警告:move_uploaded_file():无法将'/ tmp / php19Ivqt'移动到 '/var/www/vhosts/domain.co.uk/httpdocs/img/cms/20160115_090216.jpg'in /var/www/vhosts/domain.co.uk/httpdocs/admin813khufbl/filemanager/upload.php 第71行
upload.php - 第69-71行是:
if ($is_img) {
move_uploaded_file($tempFile, $targetFile);
chmod($targetFile, 0777);
}
答案 0 :(得分:0)
确保文件夹/var/www/vhosts/domain.co.uk/httpdocs/img/cms/存在。
还要确保为写入正确设置了文件权限。
答案 1 :(得分:-1)
在新创建的目录中尝试使用以下代码来上传文件。
<?php
define("SITE_NAME","project_name/"); //constant for project name
define("SITE_PATH",$_SERVER['DOCUMENT_ROOT']."/".SITE_NAME); //constant for project base directory
define("IMAGES_URL",SITE_URL."images/"); //constant for image directory
$upload_base_dir=IMAGES_URL;
$upload_time_dir=date('Y')."/".date('m')."/".date('d')."/"; // setup directory name
$upload_dir = $upload_base_dir.$upload_time_dir;
if (!file_exists($upload_dir)) {
mkdir($upload_dir, 0777, true); //create directory if not exist
}
$image_name=basename($_FILES['image']['name']);
$image=time().'_'.$image_name;
move_uploaded_file($_FILES['image']['tmp_name'],$upload_dir.$image); // upload file
?>