[英]PHP Warning: move_uploaded_file(): Unable to move/failed to open stream: Permission denied
[英]PHP/IIS copy()/move_uploaded_file() failed to open stream: Permission denied Warning
我對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
以下是與移動文件相關的代碼。
$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運行localhost。 提前謝謝你幫助我!
在我的情況下,IUSR帳戶需要目標目錄中的權限。 不是ISS_IUSR帳戶,只是IUSR帳戶。
這意味着運行apache服務器的用戶沒有upload/
目錄的寫權限。 您可以右鍵單擊該文件夾並設置寫入所有人的權限。
更新
這可能是因為您的PHP處於安全模式並且不執行將一個文件移動到另一個文件之類的命令。 檢查你的php.ini上的safe_mode
和safe_mode_exec_dir
並試驗它們。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.