In Codeigniter framework delete image file from the directory use unlink() function.
store the image name in a variable then define the image path in the unlink function and call the image variable. For example:
unlink("assets/images/".$img_name);
Delete and Unlink the image file in Codeigniter while deleting records from the database. Follow this code:
$this->db->where('image_id',$this->input->post('id')); $result=$this->db->delete('table name'); @unlink("./assets/images/".$this->input->post('img')); if($result){ echo "delete"; }else{ echo "error"; }
Question and answer is powered by AnsPress.io