简体   繁体   English

PHP / IIS copy()/ move_uploaded_file()无法打开流:权限被拒绝警告

[英]PHP/IIS copy()/move_uploaded_file() failed to open stream: Permission denied Warning

I am relatively new to web development and currently ran into an error I can't solve. 我对Web开发比较陌生,目前遇到了一个我无法解决的错误。

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: 我在输入“ 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

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."; 
}

I am using Windows 8.1 and using IIS to run localhost. 我使用Windows 8.1并使用IIS运行localhost。 Thank you in advance for helping me out!! 提前谢谢你帮助我!

In my situations, the IUSR account needed permissions in the destination directory. 在我的情况下,IUSR帐户需要目标目录中的权限。 Not the ISS_IUSR account, just the IUSR account. 不是ISS_IUSR帐户,只是IUSR帐户。

That means that user who is running the apache server does't have write permissions for upload/ directory. 这意味着运行apache服务器的用户没有upload/目录的写权限。 You can right click the folder and set permission for writing to everyone. 您可以右键单击该文件夹并设置写入所有人的权限。

Update 更新

It might be because your PHP is in safe mode and doesn't execute commands like move one file to another . 这可能是因为您的PHP处于安全模式并且不执行将一个文件移动到另一个文件之类的命令。 Check your php.ini for safe_mode and safe_mode_exec_dir and experiment with them. 检查你的php.ini上safe_modesafe_mode_exec_dir并试验它们。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 PHP警告:move_uploaded_file():无法移动/无法打开流:权限被拒绝 - PHP Warning: move_uploaded_file(): Unable to move/failed to open stream: Permission denied php 文件上传错误警告 move_uploaded_file 无法打开 stream 权限被拒绝 - php file upload error warning move_uploaded_file failed to open stream permission denied in 警告:move_uploaded_file无法打开流:权限被拒绝的PHP文件 - Warning: move_uploaded_file failed to open stream: Permission denied PHP file move_uploaded_file无法打开流和权限被拒绝错误 - move_uploaded_file failed to open stream and Permission denied error move_uploaded_file 无法打开 stream:权限被拒绝 - Mac - move_uploaded_file failed to open stream: Permission denied - Mac move_uploaded_file 无法打开流:权限被拒绝 Mac - move_uploaded_file failed to open stream: Permission denied Mac move_uploaded_file给出:无法打开流:权限被拒绝 - move_uploaded_file gives: failed to open stream: Permission denied 上传文件警告:move_uploaded_file(../ view / pictureswhy.PNG):无法打开流:权限被拒绝 - Upload file Warning: move_uploaded_file(../view/pictureswhy.PNG): failed to open stream: Permission denied 警告:move_uploaded_file(../ project / discussdesk.xlsx):无法打开流:权限被拒绝 - Warning: move_uploaded_file(../project/discussdesk.xlsx): failed to open stream: Permission denied 警告:move_uploaded_file(** Path **):无法打开流:权限被拒绝 - Warning: move_uploaded_file(**Path**): failed to open stream: Permission denied in
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM