I'm uploading images in codeigniter, it's working great. But when I try to update the images, codeigniter automatically adds 1 at the end of each image. Which will add unused images in my images directory. How can I overwrite the existing image instead of giving it a new name and saving it?
Asked
Active
Viewed 2.3k times
8
-
some code would be nice – user20232359723568423357842364 Jul 10 '13 at 16:29
1 Answers
25
You should supply the overwrite
config parameter
$config['upload_path'] = './uploads/';
$config['overwrite'] = TRUE;
$this->load->library('upload', $config);
$this->upload->initialize($config);
See the Documentation for upload preferences
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.

user20232359723568423357842364
- 4,624
- 1
- 18
- 28
-
1how to overwrite if different file type, because user may upload any type, so how can we solve that? – 151291 Jan 11 '16 at 13:36