2023-01-13 358
打印出错误的原因。
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);
知识点扩展:
语句:rename(oldname,newname,context)
参数 | 描述 |
oldname | 必需,规定要重命名的文件或目录. |
newname | 必需,规定文件或目录的新名称 |
context | 必需,规定文件句柄的环境,context 是可修改流的行为的一套选项 |
注释:在 php 4.3.3 之前,rename() 不能在基于 *nix 的系统中跨磁盘分区重命名文件.
注释:用于 oldname 中的封装协议必须和用于 newname 中的相匹配.
注释:对 context 的支持是 php 5.0.0 添加的.
以上所述是小编给大家介绍的php rename错误原因的查找方法,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对77isp云服务器技术网的支持!
原文链接:https://77isp.com/post/25423.html
=========================================
https://77isp.com/ 为 “云服务器技术网” 唯一官方服务平台,请勿相信其他任何渠道。
数据库技术 2022-03-28
网站技术 2022-11-26
网站技术 2023-01-07
网站技术 2022-11-17
Windows相关 2022-02-23
网站技术 2023-01-14
Windows相关 2022-02-16
Windows相关 2022-02-16
Linux相关 2022-02-27
数据库技术 2022-02-20
抠敌 2023年10月23日
嚼餐 2023年10月23日
男忌 2023年10月22日
瓮仆 2023年10月22日
簿偌 2023年10月22日
扫码二维码
获取最新动态