I am using code-igniter. In my project i would like to delete the specific image in folder(artical_images). If i try to use delete_files() option it deletes all the images in the folder when use the code like,
public function delete_post($value='$id')
{
$query=$this->db->query("select artical_profile from articals where artical_id='$value' ");
$img_name=$query->result()[0]->artical_profile;
//echo $img_name;
delete_files('./artical_images/',TRUE);
// $this->db->where('artical_id',$value);
//$this->db->delete('articals');
exit();
}
But when i include the specific image name taken from db and include with delete file path it doesn't work.The code is below,
public function delete_post($value='$id')
{
$query=$this->db->query("select artical_profile from articals where artical_id='$value' ");
$img_name=$query->result()[0]->artical_profile;
//echo $img_name;
delete_files('./artical_images/$img_name',TRUE);
// $this->db->where('artical_id',$value);
//$this->db->delete('articals');
exit();
}
even i included the realpath option it also not works,
public function delete_post($value='$id')
{
$query=$this->db->query("select artical_profile from articals where artical_id='$value' ");
$img_name=$query->result()[0]->artical_profile;
$img_name=realpath(APPPATH . '/artical_images/$img_name');
delete_files('$img_name',TRUE);
echo $img_name;
// $this->db->where('artical_id',$value);
//$this->db->delete('articals');
exit();
}
please give some idea to delete the files,