Manish Tiwari Manish Tiwari - 1 year ago 220
PHP Question

How to unlink image and delete from database using codeigniter in php

I have upload images in rooturl + uploads/slider
and image name store in database slider_image.

I want to delete slider_image from databse and also delete from folder.

my folder location :




I got an warning error :

Severity: WarningMessage: unlink(): http does not allow unlinking

my model code:

public function deleteSlider($sliderID)
$this->db->delete('slider_tbl',array('slider_id' => $sliderID));
$path = base_url("uploads/slider/".$result[0]->slider_image);
if($this->db->affected_rows() >= 1){
return TRUE;
} else {
return FALSE;

Answer Source

Try Changing your $path.

$path = base_url("uploads/slider/".$result[0]->slider_image);


$path = "./uploads/slider/" . $result[0]->slider_image;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download