PHP上傳問題獲取錯誤0,但move_uploaded_file()返回false。當我打印出$ _FILES我得到PHP上傳問題獲取錯誤0,但move_uploaded_file()返回false
Array ([uploadedfile] => Array ([name] => flashlog.txt [type] =>
text/plain [tmp_name] => /tmp/php0XYQgd [error] => 0 [size] => 3334))
我使用了一個基本的HTML/PHP的教程這讓我相信,這可能是服務器問題。我檢查了php.ini,並且已經upload_max_filesize:2M,post_max_size:8M。所以我很困惑,因爲我認爲0的錯誤告訴我它是成功的。
我正在使用的代碼是
<?php
// Where the file is going to be placed
$target_path = 'Test/';
$target_path = $target_path. basename($_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path))
{
echo "The file ". basename($_FILES['uploadedfile']['name']).
" has been uploaded";
}
else
{
echo "There was an error uploading the file, please try again!";
echo print_r($_FILES);
}
?>
到底什麼是給你一個錯誤的代碼?順便說一句,請**將您的代碼縮進4格**以正確格式化。 – deceze 2010-07-22 04:35:03
你提出了錯誤報告級別嗎?如果目的地出了問題,'move_uploaded_file'應該發出警告,告訴你什麼是錯的。 – deceze 2010-07-22 05:04:47