Arul
Arul

Reputation: 111

How to delete image in database and path in codeigniter

I have an image upload form and I have uploaded the image successfully and tried deleting the image, but it deletes only database and I don't know how to delete the path.(how to use unlink) here my code

     function deleteconf($data){
         $update_id=$this->uri->segment(3);
         $query= $this->_delete($update_id);
         redirect('banner/manage');
     }

    function upload(){ 
     if($this->input->post('upload')){
       $data['banner_name']    =$this->input->post('banner_name',TRUE);
       $data['banner_img1']    =$_FILES['files']['name'][0];
       $config=array(
        'allowed_types' => 'jpg|jpeg|png|gif',
        'upload_path' => $this->gallery_path,
        'max_size' => '2000'
        );

        $this->load->library('upload');
        $this->upload->initialize($config); 
        if($this->upload->do_upload()){
              $data['images']=$this->save_gallery($data);
            }else{
            echo $this->upload->display_errors();
        }
        $image_data=$this->upload->data();
    }
        $data['images']=$this->get_images();
        $data['view_file']='banner_form';
        $this->load->module('template');
        $this->template->one_col_temp($data);
}

Upvotes: 0

Views: 1073

Answers (2)

Azam Alvi
Azam Alvi

Reputation: 7055

Try this one

@unlink(PATH_DIR.'uploads/xyz.jpg');

Upvotes: 0

Snehal S
Snehal S

Reputation: 875

You can use unlink and pass it your image path for example

@unlink('MY_UPLOAD/file1.jpg');

Upvotes: 1

Related Questions