Friday, 28 August 2015

MULTIPLE DELETE IMAGES IN FOLDER ALSO IN DATABASE

Tutorial about delete multiple images in folder also in database, let's quick

Here is Controller

 public function hapus($tes_id)  
   {  
   $images= $this->db->query("SELECT * FROM `testimonial` tes_id='$tes_id'")->row_array();  
    $image=$images['tes_image'];  
   $image1=$images['testi_img1'];  
   $image2=$images['testi_img2'];  
   $image3=$images['testi_img3'];  
   $image4=$images['testi_img4'];  
   $image5=$images['testi_img5'];  
   $image6=$images['testi_img6'];  
   $image7=$images['testi_photo'];  
   $image8=$images['tes_beforeafter'];  
    $file = array($image,$image1,$image2,$image3,$image4,$image5,$image6,$image7,$image8);  
   $arrlength = count($file);  
  for($x = 0; $x < $arrlength; $x++) {  
  unlink('uploads/testimoni/' . $file[$x]);  
  }  
  $this->testimoni_model->hapus($tes_id);//  
  redirect ('admin/testimonial');   
 }  

Here is Model
 function hapus($tes_id)  
 {  
  $this->db->where('tes_id',$tes_id);  
  $this->db->delete('testimonial');  
 }   

Thanks for visiting me, hope this help your projects !

Regards !

No comments:

Post a Comment