這是怎麼回事?PHP FileUpload錯誤
<form method="post" enctype="multipart/form-data" action="php/api/member_settings_profile_avatar.php">
<input type="file" name="settings_choose_avatar" id="settings_choose_avatar">
<input type="submit" value="Upload" />
</form>
PHP/API/member_settings_profile_avatar.php,2號線:
move_uploaded_file($_FILES["settings_choose_avatar"]["tmp_name"], "img/test.png");
我得到在提交有效的PNG文件以下錯誤:
Warning: move_uploaded_file(img/test.png): failed to open stream: No such
file or directory in /customers/4/1/a/mysitenamehere.com/httpd.www/php/api
/member_settings_profile_avatar.php on line 2 Warning: move_uploaded_file():
Unable to move '/customers/4/1/a/mysitenamehere.com/tmp/phpeN9wyk' to
'img/test.png' in /customers/4/1/a/mysitenamehere.com/httpd.www/php/api
/member_settings_profile_avatar.php on line 2
是否有問題我的主人還是什麼?
路徑是否存在?嘗試上傳之前是否創建了路徑(mkdir)?路徑是否正確? –
如果對@TopQuestions問題的答案都是肯定的,你是否檢查文件夾中的is_writable? –
你確定你的路徑是否正確,你想將圖像存儲在'/ php/api/img'文件夾中還是你的意思是'/ img'(都是相對於web-root的)? – jeroen