Я хочу импортировать CSV в PHP codeigniter.am, получая ошибку.это мой контроллер
function importcsv() {
$data['error'] = ''; //initialize image upload error array to empty
$config['upload_path'] = './uploads/csv/';
$config['allowed_types'] = 'csv';
$config['max_size'] = '1000';
$this->load->library('upload', $config);
// If upload failed, display error
if (!$this->upload->do_upload()) {
$data['error'] = $this->upload->display_errors();
$this->load->view('cforce/enquiryform');
} else {
$file_data = $this->upload->data();
$file_path = './uploads/csv/'.$file_data['file_name'];
if ($this->csvimport->get_array($file_path)) {
$csv_array = $this->csvimport->get_array($file_path);
var_dump($csv_array);die;
foreach ($csv_array as $row) {
$insert_data = array(
'name'=>$row['name'],
'subject'=>$row['subject'],
'mark'=>$row['mark'],
);
$this->Adminpanelmodel->insert_csv($insert_data);
}
$this->session->set_flashdata('success', 'Csv Data Imported Succesfully');
redirect(base_url().'csv');
//echo "<pre>"; print_r($insert_data);
} else
$data['error'] = "Error occured";
$this->load->view('cforce/enquiryform');
}
}