update and override the image using codeignater : **I'm stuck on a problem with updating image. i did upload the multiple image    and inserted in database but i can not override these images in database or my upload folder how can i override the images in my upload folder and my database 'm stuck on a problem with updating image. i did upload the multiple image and inserted in database but i can not override these images in database or my upload folder how can i override the images in my upload folder and my database**  

 public function edit_package($package_id){
        
        $pname      = $this->input->post('pname'); 
    	$pdur       = $this->input->post('pdur');
    	$pdelprice  = $this->input->post('pdelprice');
    	$price      = $this->input->post('price');
    	$pcat       = $this->input->post('pcat');
    	$pc         = $this->input->post('pc'); 
    	$ploc       = $this->input->post('ploc');
    	$pcat       = $this->input->post('pcat');
    	$accom1     = $this->input->post('accom1');
    	$accom2     = $this->input->post('accom2');
    	$accom3     = $this->input->post('accom3');
    	$accom4     = $this->input->post('accom4');
    	$accom5     = $this->input->post('accom5');
    	$accom6     = $this->input->post('accom6');
    	
    	// Displaying Errors in view

		$this->form_validation->set_error_delimiters('<span style="color:red;">', '</span>');
		
		$this->form_validation->set_rules('pname', 'Package Name', 'required');
		
		$this->form_validation->set_rules('pdur', 'Package Duration', 'required');
		
		$this->form_validation->set_rules('price', 'Package Price', 'required');

		$this->form_validation->set_rules('pdelprice', 'Package offer Price', 'required');

		$this->form_validation->set_rules('pc', 'Places Covered', 'required');

		$this->form_validation->set_rules('pcat', 'Package Category', 'required');

		$this->form_validation->set_rules('ploc', 'Package Location', 'required');


		if ($this->form_validation->run() == False)
		{                                                              
			$data['editPackage']  = $this->Packages_model->editPackageVlaues($package_id);
			$data['editPackage']  = $this->Packages_model->editPackageVlaues($package_id);
			$data['editLocation']  = $this->Packages_model->edit_location();

			$data['editPackCate'] = $this->Packages_model->getCategoryName();

			$data['pkg_cat']      = $this->Packages_model->get_pkg_cat();
			$data['pkg_loc']      = $this->Api_location_model->get_locations();

			$this->load->view('Admin_panel/admin_assets');
	        $this->load->view('Admin_panel/panel');
	        $this->load->view('Admin_panel/Packages/edit_package',$data);
	        $this->load->view('Admin_panel/footer');
	    }

	    	 extract($_POST);
		       if(isset($update_package))
		        {
		            $filesCount = count($_FILES['pkg_img']['name']);

		            for($i = 0; $i < $filesCount; $i++)
	                 {

						$_FILES['userFile']['name']     = $_FILES['pkg_img']['name'][$i];
						$_FILES['userFile']['type']     = $_FILES['pkg_img']['type'][$i];
						$_FILES['userFile']['tmp_name'] = $_FILES['pkg_img']['tmp_name'][$i];
						$_FILES['userFile']['error']    = $_FILES['pkg_img']['error'][$i];
						$_FILES['userFile']['size']     = $_FILES['pkg_img']['size'][$i];


		                $config['upload_path']          = 'resources/neeraj/';
		                $config['allowed_types']        = 'gif|jpg|png|jpeg|GIF|JPEG|PNG|JPG';
		                $config['overwrite']            = TRUE;
		                $config['max_size']             = 2048000;
		                $config['max_width']            = 1024;
		                $config['max_height']           = 768;

		                $this->upload->initialize($config);
						if($this->upload->do_upload())
			            {
							$fileData[] = $this->upload->data();
							$fileName   = $fileData['file_name'];
							$images[]   = $fileName;

			            	$error = array('error' => $this->upload->display_errors());

			                $fileName = $this->upload->data('file_name');

			                if($this->Packages_model->update_packages($package_id,$pname,$pdur,$pdelprice,$price,$pcat,$ploc,$pc,$accom1,$accom2,$accom3,$accom4,$accom5,$accom6,$fileName))
			                    {
			                        $this->session->set_flashdata('package_update','Package Updated successfully');

			                        redirect('Packages_ctrl/display_packages');
			                    }

								else
							    {
									//upload the new image
									
									$upload_data = $this->upload->data();
									
									$fileName = $upload_data['file_name'];

										 if($_POST){

										 	 $data = array('pkg_img'=>$fileName);

											 	 //update
											$this->Packages_model->update_packages($data);
										 }

							        echo "<script> alert('Please Select the Hotel Image');
									            	window.location.href='add_packages';
									      </script>";

							    }		            
			            }
	                 }
		}

	    }