本文介绍了PHP:将文件上传到网络共享文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a problem uploading file to a network shared folder. I can connect to the folder by using windows authentication in IE. The script is as followed:

$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!";
}

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

when i ran it , I got an error message read:

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

I thought that's because windows authentication doesn't work this way. Is there a way I can upload the file by using username/password? Any thoughts would be appreciated.

推荐答案

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

When you are running a PHP script from the browser, you are not running it under your user account. You are running under whatever the HTTP server uses as the user name. So even if you have access to the folder, the server may not. The easiest fix is to give the server write permission to that folder.

这篇关于PHP:将文件上传到网络共享文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 09:14