Responsive Advertisement

Update Images delete in Codeigniter


Update Images delete in Codeigniter


Image...

When you update images then your image will be delete then you use

A input tag and pass the value. Example Given blow....

(HTML)

<div>
<input class="brow-mainborsty" id="exampleInputFile"  type="file" name="img">
<input type="hidden" name="old_img" value="<?= $client['client_img'] ?>" required="">
</div>

<div class="col-md-4">
<img class="img_style_banner" src="<?php echo base_url();?>uploads/<?= $client['client_img'] ?>">
                     
    <input type="hidden" name="service_icon" value="icn_wireless.png" required="">
       </div>

(Codeigniter Code In Controller)

Start.

if($this->input->post()){
$inserclients['client_name'] = $this->input->post('client_name');
$inserclients['client_img'] = $this->input->post('old_img');
$config['upload_path']   = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
      $this->load->library('upload', $config);
      if ($this->upload->do_upload('img'))
      {
          $data = array('upload_data' => $this->upload->data());
          $img = $data['upload_data']['file_name'];
          $inserclients['client_img'] = $img;
      }
            $this->admin_model->update_client($id,$inserclients);
            $this->session->set_flashdata('update_client', 'Client Information Updated Successfully');
            redirect("admin/view_clients");
}


1)First you mention the value of ('old_img') in input name field
2) You Declair the value in post this type Exp. " $inserclients['client_img'] = $this->input->post('old_img');"
3)then you upload the images and your images will not we deleted when you will update forum.

Post a Comment

0 Comments