我正在尝试使用 PHP move_uploaded_file 将文件上传到服务器,但出现以下错误:
Warning: move_uploaded_file() [function.move-uploaded-file]: The second argument to copy() function cannot be a directory in /Users/Rick/Sites/upload/upload.php on line 7
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/Applications/XAMPP/xamppfiles/temp/phpDlCZUd' to '/Users/Rick/Sites/upload/uploads/richardgregson' in /Users/Rick/Sites/upload/upload.php on line 7
下面是我的代码,没什么复杂的。
if($_POST["upload"]){
$target_path = "/Users/Rick/Sites/upload/uploads/" . $_POST["name"];
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)){
echo "<div class='success'>The file " . "<span class='filename'>" . basename( $_FILES['uploadedfile']['name']) . "</span>" . " has been uploaded</div>";
} else {
echo "<div class='error'>There was an error uploading the file, please try again!</div>";
}
}
它正在写入的文件夹的权限是正确的。我不明白错误“不能是目录,因为参数是我们将文件移动到的位置,所以它必须是目录..”
谢谢
瑞克