Overwrite previous file when loading image in codeigniter

I upload images to codeigniter, it works great. But when I try to update the images, codeigniter automatically adds 1 to the end of each image. Which will add unused images to the image catalog. How can I overwrite an existing image instead of giving it a new name and saving it?

+6
source share
1 answer

You must specify an overwrite configuration parameter

 $config['upload_path'] = './uploads/'; $config['overwrite'] = TRUE; $this->load->library('upload', $config); $this->upload->initialize($config); 

See Documentation for download settings.

Preference: Rewrite

Default value: FALSE

Parameters: TRUE / FALSE (logical)

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

+19
source

Source: https://habr.com/ru/post/949141/


All Articles