我在 codeigniter 中上传图片,效果很好。但是当我尝试更新图像时,codeigniter 会自动在每个图像的末尾添加 1。这将在我的图像目录中添加未使用的图像。我怎样才能覆盖现有图像而不是给它一个新名称并保存它?
最佳答案
您应该提供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.
关于php - 在 codeigniter 中上传图像时覆盖以前的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17575999/