------------------错误---------------------------- -
The filename ./upload/1407500591-CI1.xlsx is not readable
-------------------详情-------------------------- < / p>
-------------- controller ----------------------------
public function import_data()
{
if($_POST['sheet_name'])
{
$values=$this->validate($_POST);
if(isset($_FILES))
{
$config['upload_path'] = './upload/';
$config['allowed_types'] = 'xlsx';
$config['max_size'] = '100000';
$config['file_name'] = time().'-'.$_POST['sheet_name'];
$this->load->library('upload', $config);
$this->upload->initialize($config);
if (!$this->upload->do_upload()) {
echo $error = $this->upload->display_errors();
}
$req['image_url']=$this->upload->do_upload();
$this->excel_reader->read('./upload/'.$req['image_url']);
// Get the contents of the first worksheet
$worksheet = $this->excel_reader->sheets[0];
//print_r($worksheet);
//$data = new Spreadsheet_Excel_Reader($config['file_name']);
$numRows = $worksheet['numRows']; // ex: 14
$numCols = $worksheet['numCols']; // ex: 4
$cells = $worksheet['cells']; // the 1st row are usually the field's name
//print_r($cells );
$rowCount = count($cells);
$data['sheet_id']=$this->profile_model->createDatasheet($values);
$data['data_id']=-1;
for($i=2;$i<=$rowCount;$i++)
{
$data["profile_picture"]= isset($cells[$i][1]) ? $cells[$i][1] : '';
$data["name"] = isset($cells[$i][2]) ? $cells[$i][2] : '';
$data["country"]= isset($cells[$i][3]) ? $cells[$i][3] : '';
$data["city"]= isset($cells[$i][4]) ? $cells[$i][4] : '';
$data["email"]= isset($cells[$i][5]) ? $cells[$i][5] : '';
$data["skype"]= isset($cells[$i][6]) ? $cells[$i][6] : '';
$data["phone"]= isset($cells[$i][7]) ? $cells[$i][7] : '';
$data["star_rating"]= isset($cells[$i][10]) ? $cells[$i][10] : '';
$data["hourly_rate"]= isset($cells[$i][11]) ? $cells[$i][11] : '';
$data["tag_line"]= isset($cells[$i][12]) ? $cells[$i][12] : '';
$data["description"]= isset($cells[$i][8]) ? $cells[$i][8] : '';
$req['sheet_data_id']=$this->profile_model->insertDatasheetItems($data);
}
//$req['image_url']=$data['website_name']."/i".$data['sheet_id']."/$count-".time().$path_parts['basename'];
//$this->save_image($file,$config['upload_path'].$req['image_url']);
$this->profile_model->insertDatasheetImages($req);
redirect('/modify/user_scrape_data_display/'.$data['sheet_id']);
}
}
}
答案 0 :(得分:1)
CI库仅识别.xls文件。将文件从.xlsx重命名为.xls,它应该可以正常工作。