嘗試將上傳的文件移動到服務器上的目錄時,我一直收到此錯誤。move_uploaded_file失敗
警告:move_uploaded_file()以[function.move上傳文件]:無法 '/ TMP/phposlycV' 移動到「/home/star/mywebsite.org/view/PDFs/Elections/65.PDF '
這是我的代碼。
if ($_FILES['ufile']['type'] == "application/pdf") {
$db->exec("INSERT INTO `my_candidates` (`Type`, `ElecName`, `ExpDate`, `FirstName`, `LastName`, `State`, `Bio`) VALUES ('$Type', '$ElecName', '$ExpDate', '$FirstName', '$LastName', '$State', '$Bio')");
$sql2 = "SELECT max(ID) AS `ID` FROM `my_candidates` WHERE `Type` = '$Type' AND `ElecName` = '$ElecName' AND `FirstName` = '$FirstName' AND `LastName` = '$LastName'";
$newFileNameID = implode(' ', $db->query($sql2));
$new_file_name=$newFileNameID.$Ext;
rename($_FILES['ufile']["tmp_name"], $new_file_name);
$tempDir = $_SERVER['DOCUMENT_ROOT'] . "/PDFs/Elections/";
if (move_uploaded_file($_FILES['ufile']['tmp_name'], $tempDir . $new_file_name)) {
echo "Uploaded";
} else {
echo "Not Uploaded";
}
我的那個目錄的chmod是720.我一直在敲我的頭幾個小時。任何指針,你們可以拋出我的方式將不勝感激。有趣的事情,雖然它確實上傳到我的$_SERVER[DOCUMENT_ROOT]
目錄仍然錯誤。
這兩個目錄都有權限..check最大執行時間..max上傳大小 – zod 2012-04-03 14:48:37
您應該有chmod 755文件夾和644文件。 – Christian 2012-04-03 14:50:57
你指的是zod的php.ini文件? – wowzuzz 2012-04-03 14:51:52