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' = $fil ..
打印出错误的原因。
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错误原因的查找方法的文章就介绍到这了,更多相关php rename错误原因内容请搜索我们以前的文章或继续浏览下面的相关文章希望大家以后多多支持我们!
本文标题为:php rename错误原因的查找方法
![](/xwassets/images/pre.png)
![](/xwassets/images/next.png)
- laravel通用化的CURD的实现 2023-03-17
- Laravel balde模板文件中判断数据为空方法 2023-08-30
- php微信公众号开发之秒杀 2022-11-23
- PHP仿tp实现mvc框架基本设计思路与实现方法分析 2022-10-18
- laravel实现按月或天或小时统计mysql数据的方法 2023-02-22
- PHP简单实现二维数组的矩阵转置操作示例 2022-10-02
- windows下9款一键快速搭建PHP本地运行环境的好工具(含php7.0环境) 2023-09-02
- 用nohup命令实现PHP的多进程 2023-09-02
- PHP中PDO事务处理操作示例 2022-10-15
- PHP实现微信支付(jsapi支付)流程步骤详解 2022-10-09