You could use a helper to return the relevant config:
// /system/application/helpers/upload_config_helper.php
<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
if ( ! function_exists('upload_config')){
function upload_config($conf){
switch($conf){
case 'avatar':
$config['allowed_types'] = 'png|jpg';
$config['max_size'] = '1000';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$config['upload_path'] = '/avatars';
return $config;
break;
case 'profile_pic':
$config['allowed_types'] = 'jpg|gif';
$config['max_size'] = '1000';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$config['upload_path'] = '/profile/pics';
return $config;
break;
}
}
}
?>
then in your controller :
$this->load->helper('upload_config_helper');
$avatar_config=upload_config('avatar');
$this->load->library('upload', $avatar_config);
$this->upload->initialize($avatar_config);