Php 在本地xampp服务器上上载图像时出现权限被拒绝错误

Php 在本地xampp服务器上上载图像时出现权限被拒绝错误,php,upload,Php,Upload,xampp中的htdocs文件夹具有777权限,我可以在那里手动复制alter任何文件,但将文件上载到子文件夹会出错。我的代码是: <?php define ('MAX_FILE_SIZE', 1024 * 50); if (array_key_exists('submit', $_POST)) { // define constant for upload folder define('UPLOAD_DIR', '/opt/lampp/htdocs/properties/'); // r

xampp中的htdocs文件夹具有777权限,我可以在那里手动复制alter任何文件,但将文件上载到子文件夹会出错。我的代码是:

<?php
define ('MAX_FILE_SIZE', 1024 * 50);
if (array_key_exists('submit', $_POST)) {
// define constant for upload folder
define('UPLOAD_DIR', '/opt/lampp/htdocs/properties/');
// replace any spaces in original filename with underscores
$file = str_replace(' ', '_', $_FILES['image']['name']);
// create an array of permitted MIME types
$permitted = array('image/gif', 'image/jpeg', 'image/pjpeg','image/png');
// upload if file is OK
if (in_array($_FILES['image']['type'], $permitted)
  && $_FILES['image']['size'] > 0 
  && $_FILES['image']['size'] <= MAX_FILE_SIZE) {
switch($_FILES['image']['error']) {
  case 0:
    // check if a file of the same name has been uploaded
    if (!file_exists(UPLOAD_DIR . $file)) {
// move the file to the upload folder and rename it
$success = move_uploaded_file($_FILES['image']['tmp_name'], UPLOAD_DIR $file);
} else {
$result = 'A file of the same name already exists.';
}
if ($success) {
$result = "$file uploaded successfully.";
} else {
$result = "Error uploading $file. Please try again.";
}
break;
case 3:
case 6:
case 7:
case 8:
$result = "Error uploading $file. Please try again.";
break;
case 4: 
$result = "You didn't select a file to be uploaded.";
}
} else {
$result = "$file is either too big or not an image.";
}
}
?>

检查
php.ini中的
is
safe\u模式
is
on

如果只有xampp文件夹是可写的,但没有帮助,那么您也需要子文件夹是可写的

第二,只是问问

define('UPLOAD_DIR', '/opt/lampp/htdocs/properties/');

如果
lampp
是,那不应该是
xampp
?只要问一下(这也会导致移动问题)

lampp就是磁盘上的dir名称,这就是我安装它时的情况。。php.ini中的safe_模式是关闭的,chmod与htdocs dir一起应用于所有子文件夹。此外,upload_tmp_dir没有定义,错误显示它正在使用tmp,因此我将tmp文件夹设置为777权限,但仍然没有Luck。您的apache日志怎么说?
define('UPLOAD_DIR', '/opt/lampp/htdocs/properties/');