PHP/IIS copy()/move_uploaded_file()无法打开流:权限被拒绝警告 [英] PHP/IIS copy()/move_uploaded_file() failed to open stream: Permission denied Warning

查看:99
本文介绍了PHP/IIS copy()/move_uploaded_file()无法打开流:权限被拒绝警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Web开发的新手,目前遇到了我无法解决的错误.

I am relatively new to web development and currently ran into an error I can't solve.

在输入" http://localhost/index.html "之后,我使用IIS来测试php,然后选择要上传的示例文件,它将生成以下警告:

I use IIS to test my php after typing in "http://localhost/index.html" and select the example file to upload, it generates the following warnings:

Warning: move_uploaded_file(upload/Angela_Nie_resume_technical - EditedMW.doc): failed to open stream: Permission denied in C:\inetpub\wwwroot\test.php on line 26
Warning: move_uploaded_file(): Unable to move 'C:\Windows\Temp\php74F2.tmp' to 'upload/Angela_Nie_resume_technical - EditedMW.doc' in C:\inetpub\wwwroot\test.php on line 26

下面是与移动文件有关的代码.

Below is the code that is related with moving my files.

$target_dir = "upload/"; 
$target_file = $target_dir . basename( $_FILES["uploaded"]["name"]) ; 
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target_file))  {
    echo "The file has been uploaded"; 
}  
else { 
    echo "Sorry, there was a problem uploading file."; 
}

我正在使用Windows 8.1,并使用IIS运行本地主机.预先感谢您对我的帮助!

I am using Windows 8.1 and using IIS to run localhost. Thank you in advance for helping me out!!

推荐答案

这意味着运行apache服务器的用户没有upload/目录的写权限.您可以右键单击该文件夹,然后设置写给所有人的权限.

That means that user who is running the apache server does't have write permissions for upload/ directory. You can right click the folder and set permission for writing to everyone.

更新

这可能是因为您的PHP处于安全模式中,并且未执行将一个文件移动到另一个文件之类的命令.检查您的 php.ini 中的safe_modesafe_mode_exec_dir并进行试验.

It might be because your PHP is in safe mode and doesn't execute commands like move one file to another. Check your php.ini for safe_mode and safe_mode_exec_dir and experiment with them.

这篇关于PHP/IIS copy()/move_uploaded_file()无法打开流:权限被拒绝警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆