2

我在将文件上传到网络共享文件夹时遇到问题。我可以通过在 IE 中使用 Windows 身份验证连接到该文件夹​​。脚本如下:

$target_path =  '\\\\server\\images\\';
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
    echo "The file ".  basename( $_FILES['uploadedfile']['name']). 
    " has been uploaded";
} else{
    echo "There was an error uploading the file, please try again!";
}

当我运行它时,我收到一条错误消息:

警告:move_uploaded_file(\server\images\pic_firefox.jpg) [function.move-uploaded-file]:无法打开流:第 6 行 C:\xxxxxxxxx\uploader.php 中的权限被拒绝

我认为那是因为 Windows 身份验证不能以这种方式工作。有没有办法可以使用用户名/密码上传文件?任何想法将不胜感激。

4

1 回答 1

1

当您从浏览器运行 PHP 脚本时,您并没有在您的用户帐户下运行它。您正在以任何 HTTP 服务器用作用户名的方式运行。因此,即使您有权访问该文件夹,服务器也可能没有。最简单的解决方法是授予服务器对该文件夹的写入权限。

于 2010-02-19T22:32:46.107 回答