php - facing problems uploading image in a form using codegniter -


am trying include image in form, image added correctly 2 rows added in database table.

am trying include image in form, image added correctly 2 rows added in database table.

structure of table data added below:

http://i.stack.imgur.com/pnpap.png

my controller

public function addrecordtotable(){     $this->load->library('form_validation');        $this->form_validation->set_rules('client_id' , 'client_id', 'required');     $this->form_validation->set_rules('l_address' , 'location address', 'required|min_length[3]|max_length[50]');      if ($this->form_validation->run() == false) {         $this->load->model('clientaccount_model');           $data['bids']=$this->clientaccount_model->bids();         $data['loads']=$this->truckeraccount_model->loads();         $this->load->view('footer');     } else {         $array = array(                     'client_id' => $this->input->post('client_id'),                     'l_address' => $this->input->post('l_address'),         );          $record_id = $this->consignmentupload_model->adddata('consignment', $array);         $this->uploadfiles($record_id);     } }  public function uploadfiles($record_id){     $config = array(                 'upload_path'   => fcpath . "/uploads/",                 'allowed_types' => 'jpg|png|jpeg',                 'overwrite'     => true,                            );      $this->load->library('upload', $config);     $files = $_files['uploads'];      foreach ($files['name'] $key => $filename) {         $_files['uploads[]']['name']     = $files['name'][$key];         $_files['uploads[]']['type']     = $files['type'][$key];         $_files['uploads[]']['tmp_name'] = $files['tmp_name'][$key];         $_files['uploads[]']['error']    = $files['error'][$key];         $_files['uploads[]']['size']     = $files['size'][$key];          $config['file_name'] = $filename;         $this->upload->initialize($config);          if (isset($_files['uploads[]']['name']) && !empty($_files['uploads[]']['name'])) {              if ( ! $this->upload->do_upload('uploads[]')) {                 $error = array('error' => $this->upload->display_errors());              } else {                 $uploads[] = $this->upload->data();                 $array = array(                     'record_id' => $record_id,                     'filename'  => $_files['uploads[]']['name'],                     'size'      => $_files['uploads[]']['size']                 );                 $this->consignmentupload_model->adddata('consignment', $array);             }         }     }     redirect(site_url('clientaccount_ctrl')); } 

my model

public function adddata($table, $array) {     $this->db->insert($table, $array);     return $this->db->insert_id(); } 

after first insert is,  $record_id = $this->consignmentupload_model->adddata('consignment', $array);   have update same row image,  in uploadfiles instead of, $this->consignmentupload_model->adddata('consignment', $array);  make new model function updatedata() update same row inserted earlier, pass luggage_id updatedata() 

Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -