上传类、图片处理类

上传类
1.上传类的配置项

$config['upload_path'] = '文件上传的位置';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '100';//单位为kb ,php.ini 限制为 2M
$config['encrypt_name'] = 'true';//文件名随机
$config['max_width'] = '1024';//针对图片类型宽度限制 
$config['max_height'] = '768';//针对图片类型高度限制

2.加载上传类

$this->load->library('upload',$config);

3.判断是否上传成功

$this->upload->do_upload('fileName');//文件域中表单 name

4.获取上传后的数组

$this->upload->data();

5.获取上传失败的信息

$this->upload->display_errors();

6.上传类使用技巧
当多文件上传时遍历

$this->upload->initialize($config);//初始化
$this->upload->do_upload('fileName');//判断成功保存full_path

图片类
1.配置项

$config['source_image'] = $data['full_path'] ; //图片类和上传类关联

2.加载类文件

$this->load->library('image_lib');

3.初始化

$this->image_lib->initialize($config);

4.生成图片

$this->image_lib->resize();
原文地址:https://www.cnblogs.com/zc123/p/5403734.html