加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – 在codeigniter中上传图像时覆盖以前的文件

发布时间:2020-12-13 18:29:09 所属栏目:PHP教程 来源:网络整理
导读:我在codeigniter中上传图片,效果很好.但是当我尝试更新图像时,codeigniter会在每个图像的末尾自动添加1.这将在我的images目录中添加未使用的图像.如何覆盖现有图像而不是为其命名并保存? 您应该提供overwrite配置参数 $config['upload_path'] = './uploads/
我在codeigniter中上传图片,效果很好.但是当我尝试更新图像时,codeigniter会在每个图像的末尾自动添加1.这将在我的images目录中添加未使用的图像.如何覆盖现有图像而不是为其命名并保存?
您应该提供overwrite配置参数
$config['upload_path'] = './uploads/';
$config['overwrite'] = TRUE;

$this->load->library('upload',$config);

$this->upload->initialize($config);

有关上传首选项,请参阅Documentation

Preference: overwrite

Default Value: FALSE

Options: TRUE/FALSE (boolean)

Description: If set to true,if a file with the same name as the one
you are uploading exists,it will be overwritten. If set to false,a number will be appended to the filename if another with the same name exists.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读