php - Multiple file upload codeigniter not working -


i have form multiple files can uplaoded, along name field , date field. user can clone inputs , upload many certificates need. html below:

html:

<input type="file" name="certificate[]" /> <input type="text" name="certificate_name[]" class="right" /> <input type="text" name="expiry_date[]" /> 

i can upload files 1 @ time multiple uploads doesn't work, error

a php error encountered severity: warning message: is_uploaded_file() expects parameter 1 string, array given filename: libraries/upload.php line number: 161 

php:

$uid = 1;  if(isset($_files['certificate'])) {     $this->uploadcertificate($uid, $this->input->post('certificate_name'), $this->input->post('expiry_date')); }  function uploadcertificate($uid, $certificate, $expiry_date) {     $status = "";     $msg = "";     $file_element_name = 'certificate';     $certificate_name = $certificate;     if ($status != "error")     {         $config['upload_path'] = './certificate_files/';         $config['allowed_types'] = 'pdf|doc|docx|txt|png|gif|jpg|jpeg|';         $config['max_size']  = 1024 * 8;         $config['encrypt_name'] = true;          $this->load->library('upload', $config);          if (!$this->upload->do_upload($file_element_name))         {                $status = 'error';             $msg = $this->upload->display_errors();         }         else         {             $data = $this->upload->data();             $file_id = $this->savecertificate($uid, $data['raw_name'], $data['file_ext'], $certificate_name, $expiry_date);         }         if($file_id)         {             $status = "success";             $msg = "file uploaded";         }         else         {             //unlink($data['full_path']);             $status = "error";             $msg = "something went wrong when saving file, please try again.";         }     }        echo json_encode(array('status' => $status, 'msg' => $msg)); }   function savecertificate($uid, $file_name, $file_ext, $certificate_name, $expiry_date) {     ($ix=0; $ix<count($_files['certificate']); $ix++)     {         $insert_certificates = array(             'user_id' => $uid,             'certificate' => $_post['certificate_name'][$ix],             'certificate_name' => $_post['child_dob_additional'][$ix],             'expiry_date' => $_post['expiry_date'][$ix]         );          $insert = $this->db->insert('certificates', $insert_certificates);         //return $insert; //you cant return here. must let loop complete.          $insert_certificates_history = array(             'user_id' => $uid,             'certificate' => $_post['certificate_name'][$ix],             'certificate_name' => $_post['child_dob_additional'][$ix],             'expiry_date' => $_post['expiry_date'][$ix]         );          $insert = $this->db->insert('certificates_history', $insert_certificates_history);      } } 

i'm confused have went wrong. can point me in right direction. many in advance!


Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -