javascript - How to delete image from image directory after delete record in codeIgniter Framework? -
i want delete 1 or more product category form tbl_category.
where category_id,category_name,...... ,category_image these database field.
my problem when delete item delete database image still stay directory
i,e base_url.'./images/category_images/'.
how can it? needed.
this code controller:
public function manage_product_category() { $data=array(); $data['all_product_category']= $this->ehome_model- >select_all_product_category(); $data['admin_maincontent']=$this->load->view('admin/view_product_category',$data,true); $this->load->view('admin/admin_master',$data); } public function delete_product_category($category_id) { $this->super_a_model->delete_product_category_by_category_id($category_id); redirect('super_admin/manage_product_category'); }
this code model:
public function delete_product_category_by_category_id($category_id) { $this->db->where('category_id',$category_id); $this->db->delete('tbl_category'); }
you need use unlink php method: http://php.net/manual/it/function.unlink.php
$path = base_url.'./images/category_images/'.$file_name; unlink($path);
make sure set correct $file_name
, if not have it, run query db file name before delete row.
Comments
Post a Comment