function do_upload() { set_include_path(get_include_path() . PATH_SEPARATOR . './phpexcel/'); //set_include_path(' http://localhost/PHPExcel/phpexcel/'); /** PHPExcel */ include 'PHPExcel.php'; /** PHPExcel_IOFactory */ include 'PHPExcel/IOFactory.php'; /** include php_excel5 */ include 'PHPExcel/Reader/Excel5.php'; include 'uploader.php'; $uploader = new Helper_Uploader(); $max_size = $uploader->allowedUploadSize(); // 允许上传的最大值 $final = array('message' => "", 'content' => array()); if (!$uploader->existsFile('userfile')) { $final['message'] = '没有选择上传文件,或者文件上传失败'; } //取得要上传的文件句柄 if ($final['message'] == "") { $file = $uploader->file('userfile'); } $results = $this->excel_read($file->filepath()); $results = $this->format($results); $amount_list = array(); foreach ($results as $key => $item) { if (isset($item['yuanbao_amount'])) { $amount_item['yuanbao_extra'] = round($item['yuanbao_amount'] / 4); $amount_item['yuanbao_amount'] = $item['yuanbao_amount'] - $amount_item['yuanbao_extra']; $amount_item['yuanbao_huodong'] = round($item['yuanbao_amount'] / 10); } else { $amount_item['yuanbao_extra'] = $item['extra_yuanbao']; $amount_item['yuanbao_amount'] = $item['basic_yuanbao']; $amount_item['yuanbao_huodong'] = $item['huodong_yuanbao']; } $amount_item['pay_type_id'] = $item['pay_type_id']; $amount_item['method_id'] = $item['method_id']; $amount_item['domain_name'] = $item['domain_name']; $amount_item['game_id'] = $item['game_id']; $amount_item['pay_amount'] = $item['pay_amount']; $amount_item['goods_id'] = $item['goods_id']; $amount_item['currency_id'] = $item['currency']; array_push($amount_list, $amount_item); } $this->pay_model->insert_pay_amount_batch($amount_list); print_r($amount_list); $this->load->view('upload', array('error' => 'success')); }
public function update_money_flow_data() { set_include_path(get_include_path() . PATH_SEPARATOR . './phpexcel/'); //set_include_path(' http://localhost/PHPExcel/phpexcel/'); /** PHPExcel */ include 'PHPExcel.php'; /** PHPExcel_IOFactory */ include 'PHPExcel/IOFactory.php'; /** include php_excel5 */ include 'PHPExcel/Reader/Excel5.php'; include 'uploader.php'; $uploader = new Helper_Uploader(); $max_size = $uploader->allowedUploadSize(); // 允许上传的最大值 $final = array('message' => "", 'content' => array()); if (!$uploader->existsFile('money_flow')) { $final['message'] = '没有选择上传文件,或者文件上传失败'; } //取得要上传的文件句柄 if ($final['message'] == "") { $file = $uploader->file('money_flow'); } $results = $this->excel_read($file->filepath()); $results = $this->format($results); var_dump('sfdsf'); die; }