1

i have a problem in my delete function. the status showing the image and data was successfully deleted from directory and database, but when i check in the database, no data and image was deleted from directory and database. here is my delete link in view

<a class="btn btn-orange btn-xs" href="<?=base_url()?>index.php/root/slider/hapus/?id=<?=$row->id?>"><i class="fa fa-trash-o"></i></a>

here is my delete function in controller

 public function hapus(){
   $id  = $this->input->post('id'); 
   $path = './asset/slider/uploads/';
   $path1 = './asset/slider/hasil_resize/';
   $arraydelete  = array('id'=>$id);
   $rowdel = $this->Model_slider->get_byimage($arraydelete);
   @unlink($path.$path1.$rowdel->namafile);
   $this->Model_slider->get_delete($arraydelete);
   $this->session->set_flashdata("pesan", "<div class=\"col-md-12\"><div class=\"alert alert-danger\" id=\"alert\">Berhasil hapus data Gambar dan file gambar dari folder !!</div></div>");
   redirect('root/slider'); 

}

and here is my Model

var $tabel = 'slider_home';

function __construct() {
    parent::__construct();
}


function get_allimage() {
    $this->db->from($this->tabel);
    $query = $this->db->get();
    return $query->result();

}
function get_byimage($where) {
    $this->db->from($this->tabel);
    $this->db->where($where);
    $query = $this->db->get();
    if ($query->num_rows() == 1) {
        return $query->row();
    }
}
function get_delete($where){
   $this->db->where($where);
   $this->db->delete($this->tabel);
   return TRUE;
}

i need solution for this problem, every time i checked it and fix it, the result still same. Please help me

3
  • in @unlink($path.$path1.$rowdel->namafile); it should be either $path or $path1 Commented Apr 20, 2018 at 7:22
  • show your form , the anchor containing the link looking as normal link , not a post form Commented Apr 20, 2018 at 7:25
  • show your controller name pls be precise on details Commented Apr 20, 2018 at 7:38

1 Answer 1

1

Did you debug your app? Does you have id of image in your $id variable? You check POST, but send id of image in url, for this you need GET

Sign up to request clarification or add additional context in comments.

2 Comments

Please visit How to Answer
woow, how can i not be thorough, it's really work thanks, i really did'nt see that thank you for telling me.

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.