<?php
namespace Home\Controller;
use Think\Controller;
class ExcelController extends Controller {
public function indexAction() {
$this->display();
}
public function upexcelAction(){
if (! empty ( $_FILES ['file_stu'] ['name'] ))
{
$tmp_file = $_FILES ['file_stu'] ['tmp_name'];
$file_types = explode ( ".", $_FILES ['file_stu'] ['name'] );
$file_type = $file_types [count ( $file_types ) - 1];
/*判别是不是.xls文件,判别是不是excel文件*/
if (strtolower ( $file_type ) != "xls")
{
$this->error ( '不是Excel文件,重新上传' );
}
/*设置上传路径*/
$savePath = APP_PATH.'public/upfile/Excel/';2、ExcelModel.class.php 部分文件代码 出错位置<?php
namespace Home\Model;
use Think\Model;
class ExcelModel extends Model {
protected $tableName = 'products_log';
public function __construct() {
/*导入phpExcel核心类 */
require_once APP_PATH.'/PHPExcel/PHPExcel.php';
require_once APP_PATH.'/PHPExcel/PHPExcel/Writer/Excel5.php'; // 用于其他低版本xls
require_once APP_PATH.'/PHPExcel/PHPExcel/Writer/Excel2007.php'; // 用于 excel-2007 格式
}
//导入excel内容转换成数组
public function import($filePath){
$this->__construct();
$PHPExcel = new PHPExcel(); 最后 new PHPExcel() 类出错PHPExcel文件夹放在App应用下 也就是APP_PATH下
文件提交正确
当实例化PHPExcel 出错
Class 'Home\Model\PHPExcel' not found
最佳答案