Вот другой способ.
application/config/upload.php
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
$config = array(
'member_photo' => array(
'upload_path' => './uploads/member_photos/',
'allowed_types' => 'gif|jpeg|jpg|png',
'max_size' => '0',
'max_width' => '0',
'max_height' => '0',
'encrypt_name' => true
),
'pet_photo' => array(
'upload_path' => './uploads/pet_photos/',
'allowed_types' => 'gif|jpeg|jpg|png',
'max_size' => '0',
'max_width' => '0',
'max_height' => '0',
'encrypt_name' => true
),
);
application/libraries/MY_Upload.php
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class MY_Upload extends CI_Upload
{
function initialize($config = array())
{
// load config
if(!empty($config['config']))
{
$CI =& get_instance();
$CI->load->config('upload');
$autoload_config = $CI->config->item($config['config']);
if($autoload_config)
{
foreach($autoload_config as $key => $val)
{
if(empty($config[$key]))
{
$config[$key] = $val;
}
}
}
unset($config['config']);
}
parent::initialize($config);
}
}
Тогда в вашем контроллере;любые дополнительные ключи, которые вы определяете, переопределяют их в файле конфигурации:
$this->load->library('upload', array('config' => 'member_photo'));