最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
wordpress文件上传到服务器改变文件名
时间:2022-06-25 19:04:31 编辑:袖梨 来源:一聚教程网
例,利用图片高与宽生+文件名成名字
代码如下
| 代码如下 | 复制代码 |
|
add_filter( 'wp_handle_upload_prefilter', 'modify_uploaded_file_names', 20); function modify_uploaded_file_names( $image ) { |
|
例,利用年月日时分秒+千位毫秒整数
以wordpress 3.2.1为例,打开“wp-admin/includes/file.php” www.111com.net文件,找到第327行这段代码:
| 代码如下 | 复制代码 |
| // Move the file to the uploads dir $new_file = $uploads['path'] . "/$filename"; if ( false === @ move_uploaded_file( $file['tmp_name'], $new_file ) ) return $upload_error_handler( $file, sprintf( __('The uploaded file could not be moved to %s.' ), $uploads['path'] ) ); |
|
将其修改为
| 代码如下 | 复制代码 |
|
// Move the file to the uploads dir |
|
保存,重新上传文件。这样,新上传的文件,就会自动保存为“年月日时分秒+千位毫秒整数”的新文件名,并保存到相应的年月文件夹之下了。
一聚教程提醒你,这两种方法个人觉得后者更适合我们一些哦,因为按年月日时分秒+千位毫秒整数不会出现重复名字,而按图片高与宽生+文件名成名字还有可能存在重复名字
相关文章
- 虎牙网页版直达入口-虎牙直播官网网页版一键登录 03-15
- poki小游戏免费畅玩-poki免费游戏直通入口 03-15
- 暴风影音手机版官网-暴风影音手机版入口 03-15
- 谷歌浏览器网页版直达入口-Google-Chrome网页版官方访问地址 03-15
- 差差漫画官方登录页面免费入口安卓下载-差差漫画免费漫画页面在线看最新版本 03-15
- 抖音极速版赚钱新入口-抖音极速版官方网页版上线 03-15