cara replace foto yang di update gmna?

gan gimana ya kalo kita ubah foto terus update abis itu foto yang lama ke hapus gmna ya?

if ($uploadImg) {
            $config['allowed_types'] = 'jpg|gif|png';
            $config['image_library'] = 'gd2';
            $config['create_thumb'] = FALSE;
            $config['maintain_ratio'] = FALSE;
            $config['quality'] = '50%';
            $config['overwrite'] = TRUE;
            $config['width'] = 600;
            $config['height'] = 400;
            $config['max_size']      = 2048;
            $config['encrypt_name']  = FALSE;
            $this->load->library('image_lib', $config);
            $this->image_lib->resize();
            $config['upload_path']   = './assets/img/posting/';

            $this->load->library('upload', $config);

            if ($this->upload->do_upload('image')) {
                $oldImg = $this->input->get('image');
                if ($oldImg != 'default.jpeg') {
                    unlink(FCPATH . 'assets/img/profile/' . $oldImg);
                }
                $newImg = $this->upload->data('file_name');
                $this->db->set('image', $newImg);
            } else {
                $this->session->set_flashdata('message', '<div class="alert alert-danger" role="alert">' . $this->upload->display_errors() . '</div>');
                redirect('user/myPost');
            }
        }

btw ane bukan ambil dari data user, ini bukan table user

avatar werich1
@werich1

89 Kontribusi 7 Poin

Dipost 4 tahun yang lalu

Belum ada Jawaban. Jadi yang pertama Jawaban

Login untuk ikut Jawaban