Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $photo = $this->model_front->check_photo($id_foto); //here is check images by id
- if ($photo->num_rows() > 0) //check images is already exist
- {
- unlink("uploads/product/$row->foto"); //i delete the old images
- $this->db->delete('li_product_foto', array('id_foto' => $id_foto)); //deete data
- //your default setting, i use codeigntier
- //here is insert data again not update but same actually
- $config['upload_path'] = './uploads/product/';
- $config['allowed_types'] = 'gif|jpg|png';
- $config['overwrite'] = FALSE;
- $config['max_size'] = '500000';
- $this->upload->initialize($config);
- if ($this->upload->do_upload('file')) {
- $upload_data = $this->upload->data();
- $fileName = $upload_data['file_name'];
- $this->load->library('image_lib');
- $config['image_library'] = 'gd2';
- $config['source_image'] = $this->upload->upload_path.$this->upload->file_name;
- $config['create_thumb'] = FALSE;
- $config['height'] = 250;
- $config['width'] = 350;
- $config['new_image'] = "./uploads/product/";//you should have write permission here..
- $this->image_lib->initialize($config);
- $this->image_lib->resize();
- $data=array('foto'=>$fileName,
- 'id_product_post'=>$this->input->post('id_product_post_edit'),
- 'is_used'=>'1'
- $this->model_front->addfoto($data);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement