php - codeigniter getting an error while uploading file? -


i'm trying setup file upload in codeigniter function..

but no matter try do, error...

can me how solve issue?

my function in controller.

function insert_user_details(){              $this->load->library('form_validation');             $this->form_validation->set_rules('username', 'username', 'callback_username_check');             //$this->form_validation->set_rules('password', 'password', 'required');             //$this->form_validation->set_rules('email', 'email', 'required|email');             //$this->form_validation->set_rules('firstname','firstname', 'required');             //$this->form_validation->set_rules('middlename','firstname', 'required');             //$this->form_validation->set_rules('lastname','firstname', 'required');              if ($this->form_validation->run() == false)             {                 echo 'please fill in forms correctly' ;             }             else             {                 $config['upload_path'] = '../user_uploads/';                 $config['allowed_types'] = 'gif|jpg|png';                 $config['max_size'] = '100';                 $config['max_width']  = '1024';                 $config['max_height']  = '768';                 $this->load->library('upload', $config);                 $pass = $this->input->post('password');                 $pass = md5($pass);                 $data = array(                     'username'=>$this->input->post('username'),                     'password'=>$pass,                     'firstname'=>$this->input->post('firstname'),                     'middlenames'=>$this->input->post('middlename'),                     'lastname'=>$this->input->post('lastname'),                     'dateofbirth'=>date('y-m-d',strtotime($_post['dateofbirth'])),                     'addressline1'=>$this->input->post('addressline1'),                     'addressline2'=>$this->input->post('addressline2'),                     'city'=>$this->input->post('city'),                     'countryid'=>$this->input->post('countryid'),                     'nationalitycountryid'=>$this->input->post('nationalitycountryid'),                     'mobileno'=>$this->input->post('mobileno'),                     'workphoneno'=>$this->input->post('workphoneno'),                     'workphoneextention'=>$this->input->post('workphoneextension'),                     'nationaltaxnumber'=>$this->input->post('nationaltaxnumber'),                     'nationalidcardno'=>$this->input->post('nationalidcardno'),                     'maritalstausid'=>$this->input->post('ui_languageid'),                     'religionid'=>$this->input->post('religionid'),                     'photograph' => $this->upload->data(),                     'email'=>$this->input->post('email'),                     'weburl'=>$this->input->post('weburl'),                     'highesteducation'=>$this->input->post('highesteducation'),                     'userresumefile'=> 'res.jpg',                     'ui_languageid'=> $this->input->post('ui_languageid'),                     'lastlogindate'=>'2013-02-24 00:00:00',                     'lastloginip'=>'192.168.1.2',                     'remarks'=>$this->input->post('remarks'),                     'createbyuserid'=>'1',                     'createat'=>'2013-02-24 00:00:00',                     'modifiedbyuserid'=>'2',                     'modifiedat'=>'2013-02-24 00:00:00',                     'isactive'=>'1'                 );                 $table = 'sys_user_accounts';                 $this->common_model->insert_record($table, $data);                 echo 'success message' ;                 //$this->load->view('user_management/success','','true');         }     } 

here view file.

'photograph', 'id' => 'photograph', 'placeholder' => 'upload user photo', 'maxlength' => '250' ); echo form_upload($input_field_attributes); ?>

and yes used multipart

echo form_open_multipart('user_management/manage_users',array('id' => 'insert_user')); 

so can tell me why getting below error in firebug? , how solve it??

> error number: 1054  unknown column 'array' in 'field list'  insert `sys_user_accounts` (`username`, `password`, `firstname`, `middlenames`, `lastname`, `dateofbirth`, `addressline1`, `addressline2`, `city`, `countryid`, `nationalitycountryid`, `mobileno`, `workphoneno`, `workphoneextention`, `nationaltaxnumber`, `nationalidcardno`, `maritalstausid`, `religionid`, `photograph`, `email`, `weburl`, `highesteducation`, `userresumefile`, `ui_languageid`, `lastlogindate`, `lastloginip`, `remarks`, `createbyuserid`, `createat`, `modifiedbyuserid`, `modifiedat`, `isactive`) values ('hello', '1a1dc91c907325c69271ddf0c944bc72', 'fda', 'fda', 'fad', '2010-03-03', '1', 0, '1', 0, 0, '1', '1', 0, '1', 0, 0, 0, array, 0, 0, 0, 'res.jpg', 0, '2013-02-24 00:00:00', '192.168.1.2', 0, '1', '2013-02-24 00:00:00', '2', '2013-02-24 00:00:00', '1')  filename: c:\xampp\htdocs\projects\zorkif_nextgen\system\database\db_driver.php  line number: 330 

i'm not familiar ci, can see $this->upload->data(); returning array , that's why it's throwing error.

if using php 5.4 try using $this->upload->data()['file_name'] or $this->upload->data()['full_path'] , if using php 5.3 or lower, assign $this->upload->data() variable , access values via proper keys.

just before inserting var_dump($this->upload->data()); , i'm sure you'll figure out.


Comments