紧急求助!codeigniter无法调用phpexcel
我是初学codeigniter,使用其文件上传类将csv或者excel文件上传,同时,使用过phpexcel来读取内容,装入数据库。我的程序如下:
controllers/products.php文件:
$memsn = $this->session->userdata('memsn');
$this->load->library('excel_read_operat');
$groups = array('purchaser', 'salesman', 'viewer','merchant');
if ($this->ion_auth->in_group($groups))
{
$this->session->set_flashdata('message', $this->lang->line(access_denied));
$data['message'] = (validation_errors() ? validation_errors() : $this->session->flashdata('message'));
redirect('module=products', 'refresh');
}
$this->form_validation->set_rules('userfile', $this->lang->line(upload_file), 'xss_clean');
if ($this->form_validation->run() == true)
{
if ( isset($_files[userfile])){
$this->load->library('upload_photo');
$dest_dir = 'uploads/'.$memsn.'/';
$this->dest_dir_fortest = $dest_dir;
if($this->upload_photo->direct_is_exists($dest_dir)){
}else{
redirect(module=products&view=upload_csv, 'refresh');
}
$config['upload_path'] = $dest_dir;
$config['allowed_types'] = 'csv|xls|xlsx';
$config['max_size'] = '2048';
$config['overwrite'] = true;
$old_file_name = $_files[userfile][name];
$new_file_name = $this->getsystemtime().$_files[userfile][name];
$config['file_name'] = $new_file_name;
//initialize
$this->upload_photo->initialize($config);
if( ! $this->upload_photo->do_upload()){
//echo the errors
$error = $this->upload_photo->display_errors();
$this->session->set_flashdata('message', $error.$dest_dir);
redirect(module=products&view=upload_csv, 'refresh');
}
if ($this->upload_photo->file_ext == '.csv') {
$csv = $this->upload_photo->file_name;
excel_read_operat::initialized($dest_dir.$new_file_name);
$phpexcel_csv_arr_table = excel_read_operat::getarrtable_cvs();
if(!empty($phpexcel_csv_arr_table)){
$keys = array('code','name','category_id','status','description','decdesction','custprice','length','height','width','status');
$final = array();
foreach ($phpexcel_csv_arr_table as $row_csv_value){
$final[] = array_combine($keys, $value);
foreach($final as $csv_pr) {
if($this->products_model->getproductbycode($csv_pr['code'])) {
$this->session->set_flashdata('message', $this->lang->line(check_product_code). (.$csv_pr['code'].). .$this->lang->line(code_already_exist));
redirect(module=products&view=upload_csv, 'refresh');
}
}
}
在libraries/下,有excel_read_operat.php类文件,和excel文件夹,文件夹下是phpexcel.php和phpexcel文件夹。excel_read_operat.php类如下:
if ( ! defined('basepath')) exit('no direct script access allowed');