PHP: upload files to network shared folder

微笑、不失礼 提交于 2019-12-08 01:03:50

问题


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:

Warning: move_uploaded_file(\server\images\pic_firefox.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in C:\xxxxxxxxx\uploader.php on line 6

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.


回答1:


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.



来源:https://stackoverflow.com/questions/2299981/php-upload-files-to-network-shared-folder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!