Advertisement
freddy0512

edit iamges

Nov 5th, 2015
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.26 KB | None | 0 0
  1. $photo = $this->model_front->check_photo($id_foto); //here is check images by id
  2. if ($photo->num_rows() > 0) //check images is already exist
  3. {
  4.    unlink("uploads/product/$row->foto"); //i delete the old images
  5.    $this->db->delete('li_product_foto', array('id_foto' => $id_foto)); //deete data
  6.  
  7.  
  8. //your default setting, i use codeigntier
  9. //here is insert data again not update but same actually
  10.  
  11. $config['upload_path'] = './uploads/product/';
  12. $config['allowed_types'] = 'gif|jpg|png';
  13. $config['overwrite'] = FALSE;
  14. $config['max_size'] = '500000';
  15. $this->upload->initialize($config);
  16. if ($this->upload->do_upload('file')) {
  17.     $upload_data = $this->upload->data();
  18.     $fileName = $upload_data['file_name'];
  19.     $this->load->library('image_lib');
  20.     $config['image_library'] = 'gd2';
  21.     $config['source_image'] = $this->upload->upload_path.$this->upload->file_name;
  22.         $config['create_thumb'] = FALSE;
  23.     $config['height'] = 250;
  24.     $config['width'] = 350;
  25.     $config['new_image'] = "./uploads/product/";//you should have write permission here..
  26.     $this->image_lib->initialize($config);
  27.     $this->image_lib->resize();
  28.     $data=array('foto'=>$fileName,
  29.             'id_product_post'=>$this->input->post('id_product_post_edit'),
  30.             'is_used'=>'1'
  31.  $this->model_front->addfoto($data);  
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement