欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

php rename錯(cuò)誤原因的查找方法

 更新時(shí)間:2021年07月23日 08:48:09   作者:小妮淺淺  
在本篇文章里小編給大家整理的是一篇關(guān)于php rename錯(cuò)誤原因的查找方法,有需要的朋友們可以跟著學(xué)習(xí)參考下。

打印出錯(cuò)誤的原因。

error_get_last()似乎沒有返回任何內(nèi)容。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);
}

其次,可以開啟錯(cuò)誤報(bào)告:

error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);

知識(shí)點(diǎn)擴(kuò)展:

語句:rename(oldname,newname,context)

參數(shù) 描述
oldname 必需,規(guī)定要重命名的文件或目錄.
newname 必需,規(guī)定文件或目錄的新名稱
context 必需,規(guī)定文件句柄的環(huán)境,context 是可修改流的行為的一套選項(xiàng)

注釋:在 php 4.3.3 之前,rename() 不能在基于 *nix 的系統(tǒng)中跨磁盤分區(qū)重命名文件.

注釋:用于 oldname 中的封裝協(xié)議必須和用于 newname 中的相匹配.

注釋:對 context 的支持是 php 5.0.0 添加的.

到此這篇關(guān)于php rename錯(cuò)誤原因的查找方法的文章就介紹到這了,更多相關(guān)php rename錯(cuò)誤原因內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論