PHP:将文件上传到网络共享文件夹

时间:2010-02-19 22:10:53

标签: php upload networking directory shared

我在将文件上传到网络共享文件夹时遇到问题。我可以在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身份验证不能以这种方式工作。有没有办法使用用户名/密码上传文件?任何想法都将不胜感激。

1 个答案:

答案 0 :(得分:1)

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

相关问题