Image deletes while updating the content in codigniter

$this->form_validation->set_rules('avatar','avatar','callback_multiple_image_upload','trim');
            $this->form_validation->set_rules('overview','overview','trim');
            $this->form_validation->set_rules('history','history','trim');
            $this->form_validation->set_rules('pre_experience','pre_experience','trim');
            $this->form_validation->set_rules('education','education','trim');
            $this->form_validation->set_rules('joining','joining','trim|exact_length[10]|callback_validate_date|xss_clean');
            $this->form_validation->set_rules('hobbies','hobbies','trim');
            $this->form_validation->set_rules('experience','experience','trim');
            $this->form_validation->set_rules('skills','skills','trim');
            $this->form_validation->set_rules('record','record','trim');
            $this->form_validation->set_rules('achievements','achievements','trim');
            
        
            if($this->form_validation->run())
            {
                // check if avatar is uploaded
            $images = $this->session->userdata('uploaded_images');
            $this->session->unset_userdata('uploaded_images'); 
            
            $data = array(
                     'avatar' => ($images)?$images[0]['file_name']:'',
                     'thumb' => ($images)?$images[0]['thumb']:'',
                    
                    'overview' =>$this->input->post('overview'),
                    'history' =>$this->input->post('history'),
                    'pre_experience' =>$this->input->post('pre_experience'),
                    'education' =>$this->input->post('education'),
                    'joining' =>$this->input->post('joining'),
                    'hobbies' =>$this->input->post('hobbies'),
                    'experience' =>$this->input->post('experience'),
                    'skills' =>$this->input->post('skills'),
                    'record' =>$this->input->post('record'),
                    'achievements' =>$this->input->post('achievements'),
                    'modified' => date('Y-m-d H:i:s')
                    
            );
            
            
            
    public function multiple_image_upload()
    {
        $config = array();
        $config['upload_path']          = './uploads/user_avatars/';
        $config['allowed_types']        = 'gif|jpg|png';
        $config['max_size']             = 10000;
        $config['max_width']            = 10240;
        $config['max_height']           = 7680;
        $config['overwrite'] = FALSE;

        $images = array();
        //$count = (count($_FILES['avatar']['name'])>0);
        $files = $_FILES;

        if($_FILES['avatar']['name'] != null && ($count = count($_FILES['avatar']['size'])) > 0)
        
    
        {
            $files = $_FILES;
            //$files = $this->input->post('avatar');
            //echo"<pre>";print_r($files);die;
            $images = array();
            /* check if folder with year exists*/
            $current_year = date('Y');
            $path = './uploads/user_avatars/'.$current_year;

            if(is_dir($path)){
                /* do nothing */
            }else{
                /* create directory */
                @mkdir( $path , 0755, true );
            }

            $images = array();
            for($i = 0; $i < @$count; $i++) 
            {
                $config['upload_path'] = $path;
                $config['allowed_types'] = 'gif|jpg|jpeg|png';
                $config['max_size']    = '100000';
                $config['max_width']  = '102400';
                $config['max_height']  = '76800';
                $this->load->library('upload', $config);
                
                if ($this->upload->do_upload('avatar'))
                {
                    $data = $this->upload->data();
                    
                    /* create thumbnail */
                    $this->load->helper('image_thumb_helper');
                    generate_image_thumb($data['full_path'],$path,$data['file_name']);
                    
                    /* add to database */                    
                    $images[$i]['file_name'] = $current_year.'/'.$data['file_name'];
                    $images[$i]['thumb'] = $current_year.'/thumb_'.$data['file_name'];
                }else{
                    $this->form_validation->set_message('multiple_image_upload',$this->upload->display_errors());
                    return false; 
                }     
            }
            
            $this->session->set_userdata('uploaded_images',$images);
            return true;
         }
        else{
        
          return true;
        }
    }

as i update anything except image it deletes the image what to do please help

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.