php - Data inputted on separate rows when uploading an image alongside other information in a form. I am using code igniter -


data inputted on separate rows when uploading image alongside other information in form. using code igniter. image details entered on own row , other inputs name,address entered on own rows.

my controller

public function addrecordtotable(){   $this->load->model('consignmentupload_model');   $this->load->library('form_validation');    $this->form_validation->set_rules('client_id' , 'client_id', 'required'); $this->form_validation->set_rules('l_address' , 'l_address', 'required'); $this->form_validation->set_rules('l_area' , 'l_area', 'required'); $this->form_validation->set_rules('d_area' , 'd_area', 'required'); $this->form_validation->set_rules('preferred' , 'preferred', 'required'); $this->form_validation->set_rules('dom' , 'dom', 'required'); $this->form_validation->set_rules('tom' , 'tom', 'required'); $this->form_validation->set_rules('description' , 'description', 'required'); $this->form_validation->set_rules('mass' , 'mass', 'required');  if ($this->form_validation->run() == true) {     $array = array(                     'client_id' => $this->input->post('client_id'),                     'l_address' => $this->input->post('l_address'),                     'l_area' => $this->input->post('l_area'),                     'd_address' => $this->input->post('d_address'),                     'd_area' => $this->input->post('d_area'),                     'preferred' => $this->input->post('preferred'),                     'dom' => $this->input->post('dom'),                     'tom' => $this->input->post('tom'),                     'description' => $this->input->post('description'),                     //'consignment_picture' => $this->input->post('consignment_picture'),                     'mass' => $this->input->post('mass'),     );      $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();     } 

my table structure

columns - luggage_id, client_id, l_area, l_address, d_area, preferred, dom, tom, description, mass, record_id, filename, size, upload time, status, image folder uploads , on root


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -