【问题标题】:PHP: upload files to network shared folderPHP:将文件上传到网络共享文件夹
【发布时间】:2011-01-18 23:45:11
【问题描述】:

我在将文件上传到网络共享文件夹时遇到问题。我可以通过在 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]: 失败 打开流:权限被拒绝 C:\xxxxxxxxx\uploader.php 在第 6 行

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

【问题讨论】:

  • 您是否有权访问该文件夹?
  • 您确定您对该文件夹有写权限吗?尝试正常映射到驱动器,看看是否可以放入文件。
  • 是的,我无意回答这个问题,而是我现在的问题。你是我的双胞胎吗?
  • 我是来自未来的你。

标签: php upload networking directory shared


【解决方案1】:

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

【讨论】:

  • @XiZhang:我也面临同样的问题。您能否具体说明您是如何解决这个问题的?
  • @Anthony,我也有同样的问题,我有权从我的管理员那里读/写,但仍然无法打开流:无效参数警告
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-08-11
相关资源
最近更新 更多