There is a public overwrite attribute that dictates a decision to overwrite the original file. By default, a new file name is created based on the original. Here is the source from Upload.php to CI:
$this->orig_name = $this->file_name; if ($this->overwrite == FALSE) { $this->file_name = $this->set_filename($this->upload_path, $this->file_name); if ($this->file_name === FALSE) { return FALSE; } }
So, all you have to do to make rewriting work:
$this->load->library('upload', $config); $this->upload->overwrite = true;
source share