Ang*_*Nie 4 php iis warnings file-permissions file-upload
我对Web开发比较陌生,目前遇到了一个我无法解决的错误.
我在输入" http://localhost/index.html " 后使用IIS测试我的php 并选择要上传的示例文件,它会生成以下警告:
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
Run Code Online (Sandbox Code Playgroud)
以下是与移动文件相关的代码.
$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.";
}
Run Code Online (Sandbox Code Playgroud)
我使用Windows 8.1并使用IIS运行localhost.提前谢谢你帮助我!
这意味着运行 apache 服务器的用户没有upload/
目录的写权限。您可以右键单击该文件夹并设置向所有人写入的权限。
更新
这可能是因为您的 PHP 处于安全模式并且不执行诸如将一个文件移动到另一个文件之类的命令。检查php.ini中的safe_mode
和safe_mode_exec_dir
并进行试验。