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

栏目: PHP · 发布时间: 7年前

内容简介:我在codeigniter中上传图片,效果很好.但是当我尝试更新图像时,codeigniter会在每个图像的末尾自动添加1.这将在我的images目录中添加未使用的图像.如何覆盖现有图像而不是为其命名并保存?翻译自:https://stackoverflow.com/questions/17575999/overwrite-previous-file-while-uploading-image-in-codeigniter

我在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.

翻译自:https://stackoverflow.com/questions/17575999/overwrite-previous-file-while-uploading-image-in-codeigniter


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Python网络编程攻略

Python网络编程攻略

萨卡尔 (Dr.M.O.Faruque Sarker) / 安道 / 人民邮电出版社 / 2014-12-1 / 45.00元

开发TCP/IP网络客户端和服务器应用 管理本地设备的IPv4/IPv6网络接口 使用HTTP和HTTPS协议编写用途多、效率高的Web客户端 编写可使用常见电子邮件协议的电子邮件客户端 通过Telnet和SSH连接执行远程系统管理任务 使用Web服务与流行的网站交互 监控并分析重要的常见网络安全漏洞一起来看看 《Python网络编程攻略》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

在线进制转换器
在线进制转换器

各进制数互转换器

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器