<?php
class Upload_demo extends CI_Controller {
	public function index() {
	}
	
	// http://127.0.0.1:8000/CodeIgniter-3.0.0/upload_demo/file
	public function file() {
		$data ['error'] = '';
		$data ['upload_data'] = '';
		
		$this->load->helper ( 'url' );
		$this->load->view ( 'user/upload_view_demo', $data );
	}
	public function upload() {
		// 上传目录需要手动创建
		$config ['upload_path'] = './uploads/';
		$config ['allowed_types'] = 'gif|jpg|png';
		$config ['max_size'] = 100;//kb
		$config ['max_width'] = 1024;
		$config ['max_height'] = 768;
		// 上传后的文件名/不设置则默认原文件名,如果文件名冲突,则会在文件名中加入递增数字
// 		$config ['file_name'] = uniqid (); 
		
		$this->load->library ( 'upload', $config );
		
		$this->upload->do_upload ( 'pic' );//上传的input name
		$this->upload->do_upload ( 'pic2' );//上传的input name
		
		$data = array (
				'upload_data' => $this->upload->data () ,//上传成功
				'error' => $this->upload->display_errors ()//错误信息
		);
		$this->load->view ( 'user/upload_view_demo', $data );
	}
}