简体   繁体   中英

how to delete image from database and image folder in codeigniter

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

我认为这会奏效

 unlink(FCPATH.'assets/img/news_image/'.$path);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM