tangsiner 发表于 2010-1-14 12:48:40

上传,更有两种配置,怎么解决

我的表单里有两个上传控件,分别要用不同的config设置,但是我在控制器处理时,却发现只能使用一个设置,第二设置无效
说不清楚,看源码吧

第一个
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|jpeg|png';
$config['max_size'] = '120';
$config['max_width']= '120';
$config['max_height']= '120';
$config['encrypt_name'] = true;

$this->load->library('upload', $config);//载入文件上传类

第二个
$config['upload_path'] = './uploads/content/';
$config['allowed_types'] = 'gif|jpg|jpeg|png';
$config['max_size'] = '500';
$config['max_width']= '0';
$config['max_height']= '0';
$config['encrypt_name'] = true;

$this->load->library('upload', $config);//载入文件上传类


上传可以成功,但二个的配置无效,看别人的帖子说两次载入$this->load->library('upload', $config);无效,还是会用第一个的配置,所以想问一下,像我这样的情况,该怎么处理,可以先卸载第一个$this->load->library('upload', $config);再装载$this->load->library('upload', $config);吗,请高手们回答,比较急,请知道的一定告诉我

Hex 发表于 2010-1-14 17:02:42

CI 的 load 都有规避机制,第二次 load->library 无效。
第二次 load->library 改成
$this->upload->initialize($config);
CI 所有需要传配置的类库通用。

tangsiner 发表于 2010-1-14 18:36:14

好的,十分感谢你的帮助
页: [1]
查看完整版本: 上传,更有两种配置,怎么解决