php - Problems on uploading image files -


this view file form image , other data exists:

    <?php echo form_open_multipart('login/client_profile'); ?>                          <div class="form-group">                              <label>company name</label>                              <input type="text" class="form-control" name="company_name"  >                          </div>                                                     <div class="form-group">                              <label>upload profile picture</label>                 				<input type="file" name="profile_pic" accept="image/*" class="form-control"  required>                          </div>                          <div class="form-group">                              <label>mobile number</label>                              <input type="number" class="form-control" name="mobile"  required>                          </div>                          <div class="form-group">                              <label>specialist in</label>                              <input type="text" class="form-control" name="specialist_in" >                          </div>                            <div class="form-group">                              <label>position</label>                              <input type="text" class="form-control" name="position"  >                          </div>                                                        <?php                            $data7 = array(                              'type'        => 'submit',                              'value'       => 'update',                              'class'       => 'btn btn-primary ',                          );                          echo form_submit($data7);                          echo form_close();                         ?>

this controller file client.php

     public function client_profile()       {  	 $client=$this->input->post();  	 $client['profile_pic']=$this->input->post('profile_pic');  	 $this->load->model('clientmodel');  	 $email=$this->session->userdata('email_id');  	 $this->clientmodel->add_client_details($email,$client);  	 $ppic['pic']=$this->clientmodel->get_pic($email);                  $config['upload_path'] = './profile/';                  $config['allowed_types'] = 'jpg|jif|png|jpeg';                                    $this->load->library('upload', $config);                  $field = 'pic';  	            if ($this->upload->do_upload($field)) {                      $temp = $this->upload->data();                      $pic = $temp['file_name'];                                         }  		$this->load->view('client/pro_header',$ppic);          $this->load->view('client/client_dashboard',$client);     }

this model file clientmodel.php

   public function add_client_details($email, array $client)  	{  		   		return $this->db->where(['email'=>$email])  		                ->update('clients',$client);  	}       public function get_pic($login_email)  	{  		$q=$this->db->where(['email'=>$login_email])  		            ->get('clients');  		return $q->row()->profile_pic;  	}

after entering data fields other image can fetched using $this->input->post when try fetch 'profile_pic' returns nothing.and image file name not inserted in database.field 'profile_pic' there in table 'clients'

this uploading it's not checking validation

    public function upload_docs () {          if($this->input->post('action') == 'upload') {             $company_name = $input->post('company_name');             $position = $input->post('position');             $mobile = $input->post('mobile');             $specialist_in = $input->post('specialist_in');              // capture variable              $file_path = './assets/images/uploads';               if ($_files["profile_pic"]["error"] > 0) {                  $data['msg'] = 'your message';              } else {                  if(!is_dir($file_path)) @mkdir($file_path, 0777, true);                    if (move_uploaded_file($_files['profile_pic']['tmp_name'], $file_path.'/'.$_files['profile_pic']['name'])) {                         $upload_data = array('company_name'=> $company_name,'mobile'=> $mobile,'specialist_in'=> $specialist_in,'profile_pic' => $_files['profile_pic']['name']);                         $insert_id = $this->your_model->addrecord($upload_data);                         if ($insert_id) {                                 //  redirect('admin/index','refresh');                         }                   }              }         }          $data['title'] = 'upload';          $this->load->view('admin/upload',$data);  } 

Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -