Update image di codeigniter

hallo master,

saya punya controller seperti ini :

public function proses_edit_karyawan(){
$id	  = $this->input->post('id_karyawan');
$nik      = $this->input->post('nik');
$password = $this->input->post('password');
$nama     = $this->input->post('nama_karyawan');
$foto     = $_FILES['userfile']['name'];;

if($foto == '')
{
$data = array(
	'password' 	=> $password,
	'nama' 		=> $nama,
	);
	$this->db->where ('id',$id);
	$this->db->update('tbl_karyawan',$data);
	redirect('admin/karyawan');
}else{
	$path                     = './assets/foto';
	$config['upload_path']    = $path;
	$config['allowed_types'] = 	'gif|jpg|png|JPG|jpeg|JPEG';
	$config['max_size']      = 	5200;
	$config['max_width']     = 	5024;
	$config['max_height']    = 	5768;
	$this->load->library('upload', $config);

	if (!$this->upload->do_upload()){
		$error = array('error' => $this->upload->display_errors());
		//redirect('admin/karyawan');
		}else{
		$data   = array(
				'upload_data'	=> $this->upload->data());
		dataku = array(
				'password' 		=> $password,
				'nama' 			=> $nama,
				'foto' 			=> $foto
				);

			$this->db->where ('id',$id);
			$this->db->update('tbl_karyawan',$dataku);
			redirect('admin/karyawan');
		}
		}
	}

jika saya update file image nya, image yg lama tidak terhapus, adakah script yg harus ditambahkan atau script yg diatas ada yg salah ?

mohon bantuannya. Terima Kasih.

avatar Query
@Query

61 Kontribusi 6 Poin

Diperbarui 5 tahun yang lalu

1 Jawaban:

[edit] coba baca ini gan, semoga membantu => <a href=' https://sekolahkoding.com/forum/update-image-di-codeigniter-1548486259 '> https://sekolahkoding.com/forum/update-image-di-codeigniter-1548486259 </a>

eh yg nanya agan juga ya :D

avatar Ahmad554
@Ahmad554

95 Kontribusi 39 Poin

Dipost 5 tahun yang lalu

Login untuk ikut Jawaban