我有一个小问题。我有一个用于上传的自定义配置文件。我想加载设置而不用重新定义它们。Codeigniter加载自定义上传配置
好了,我的配置是这样的:
的config.php
$config['upload_path'] = 'tmp/';
$config['allowed_types'] = 'zip';
$config['file_name'] = '';
$config['max_size'] = '';
$config['encrypt_name'] = false;
$config['remove_spaces'] = true;
控制器
// Here is my problem $config[]
// How to load settings from config.php without again defining $config array
$config['upload_path'] = $this->config->item('upload_path');
$config['allowed_types'] = $this->config->item('allowed_types');
$config['file_name'] = $this->config->item('file_name');
$config['max_size'] = $this->config->item('max_size');
$config['encrypt_name'] = $this->config->item('encrypt_name');
$config['remove_spaces'] = $this->config->item('remove_spaces');
$this->load->library('upload',$config);
if(!$this->upload->do_upload())
{
$this->session->set_flashdata('error', $this->upload->display_errors());
redirect('extension/');
}
我想绕过$配置的重新定义['测试] = $ this-> config-> item('test');
这是不可能的吗?
又如何从$ this-> load-> library('upload',WHAT NOW HERE)中的配置加载声明; – Ivan 2013-04-22 14:48:41
您只需调用配置文件upload.php并将其放入您的配置文件夹。上传类将自动加载在这个自定义文件中声明的配置项。无需初始化它。看到这里:http://ellislab.com/codeigniter/user-guide/libraries/file_uploading.html,搜索“在配置文件中设置首选项” – 2013-04-22 15:02:28
是的,但在设置首选项中,他定义$ config数组在一个文件中。但我的配置数据存储在其他文件/config/upload.php我试着说你不工作 – Ivan 2013-04-22 15:10:37