|
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
//评分规则控制器
class Upload extends CI_Controller {
function __construct(){
//构造函数
parent::__construct();
$this->load->library("phpexcel");
$this->load->library("PHPExcel/iofactory");
$this->load->helper(array('form', 'url'));
}
public function index()
{
$this->load->view('upload_form', array('error' => ' ' ));
}
function upload_Excel()
{
$filePath = './uploads/';
$config['upload_path'] =$filePath; //文件上传路径。该路径必须是可写的,相对路径和绝对路径均可以
$config['allowed_types'] = 'xls'; //限制文件类型
$config['overwrite'] = true; //是否覆盖。该参数为TRUE时,如果上传文件时碰到重名文件,将会把原文件覆盖;
$config['remove_spaces'] = true; //参数为TRUE时,文件名中的空格将被替换为下划线
$config['max_size'] = '2000'; //允许上传文件大小的最大值(以K为单位)
$this->load->library('upload', $config); //初始化文件上传类
if ( ! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
echo realpath('./uploads/');
$this->load->view('upload_form', $error);
}
else
{
$data = array('upload_data' => $this->upload->data());
$this->load->view('upload_success', $data);
}
}
}
这是上传文件的控制器 根目录我也建了文件夹uploads 然后我上传的时候 只是说文件路径无效
内容就是:The upload path does not appear to be valid.
|
|