我正在寫一個PHP腳本,用於在服務器上進行文件上傳。並且代碼如下..move_uploaded_file()不起作用
$target_path = "uploaded_images/";
$target_path = $target_path . basename($_FILES['image']['name']);
if(move_uploaded_file($_FILES['image']['tmp_name'], $target_path)) {
echo "The file ". basename($_FILES['image']['name']).
" has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
但功能move_uploaded_file()以不工作,它提供了以下錯誤..
Warning: move_uploaded_file(uploaded_images/Mordent.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpOWVz7o' to 'uploaded_images/Mordent.jpg'
我已經檢查的所有permisions的文件夾,甚至php.ini中的安全模式已關閉。
請幫助我,我需要這個緊急完成。
此答案以前使用'dirname(__ FILE __)'。自PHP 5.3以來,較短的'__DIR__'可用,並且完全相同。 –