Reputation: 163
I want to delete image from database and also delete from folder where it save
My delete link is
<a href="<?php echo base_url().'user/delete_news/'.$row['id']."/".$row['image'];?>" class="confirm"><button class="btn btn-danger btn-sm">Delete</button></a>
My delete function is
function delete_news($id,$path)
{
$query = $this->db->query("DELETE FROM deleted_news WHERE id = '$id'");
unlink(base_url().'assets/img/news_image/'.$path);
if($query)
{
return 1;
}
else
{
return 0;
}
}
Please give me right solution of this problam...
Upvotes: 1
Views: 7749
Reputation:
I think this will work
unlink(FCPATH.'assets/img/news_image/'.$path);
Upvotes: 3