Daftar dan Belajar Sekarang!

cara replace foto yang di update gmna?

foto werich1
65 Kontribusi 2 Coto
2 bulan yang lalu
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


Login untuk diksusi di forum sekolah koding