1

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...

1 Answer 1

3

I think this will work

 unlink(FCPATH.'assets/img/news_image/'.$path);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.