這篇文章主要介紹php中rename錯誤怎么辦,文中介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們一定要看完!
打印出錯誤的原因。
error_get_last()似乎沒有返回任何內容。rename()返回true false,而不是異常。
if (!rename($file->filepath, $full_path)) {
$error = error_get_last();
watchdog('name', "Failed to move the uploaded file from %source to %dest", array('%source' => $file->filepath, '%dest' => $full_path));
}解決辦法
首先,最好在以下情況之前新增一些安全檢查:
if (file_exists($old_name) &&
((!file_exists($new_name)) || is_writable($new_name))) {
rename($old_name, $new_name);
}其次,可以開啟錯誤報告:
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
以上是“php中rename錯誤怎么辦”這篇文章的所有內容,感謝各位的閱讀!希望分享的內容對大家有幫助,更多相關知識,歡迎關注億速云行業資訊頻道!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。