当我编辑图像文件时,它会将文件夹中的文件加倍,有人知道如何处理吗?
控制器
**public function editHome()
{
$config['upload_path'] = './upload/images/slide/';
$config['allowed_types'] = 'gif|jpg|png';
$this->load->library('upload', $config);
//edit
$id_home = $this->input->post('id_home1', true);
$data['dm'] = $this->db->get_where('tb_home', ['id_home' => $id_home])->row_array();
if (!$this->upload->do_upload('gambar_home')) {
echo "Gagal Update";
} else {
$dd = array('upload_data' => $this->upload->data());
$dm = [
'judul_home' => $this->input->post('judul_home'),
'gambar_home' => $dd['upload_data']['file_name'],
'desc_home' => $this->input->post('desc_home'),
'status_home' => $this->input->post('status_home')
];
$this->db->where('id_home', $this->input->post('id_home', true))->update('tb_home', $dm);
}
$this->session->set_flashdata('message', '<div class="alert alert-success" role="alert"> Berhasil Update !</div>');
redirect('admin/content/home');
}**
默认情况下,codeigniter文件上传库不会用相同的名称替换上传的文件,而是用[filename]1.jpg
保存文件。如果文件名相同,您可以使用替换它
$config['overwrite'] = true; //set true to overwrite the data
$config['upload_path'] = './upload/images/slide/';
$config['allowed_types'] = 'gif|jpg|png';
$this->load->library('upload', $config);