我有一個小問題。我有一個用於上傳的自定義配置文件。我想加載設置而不用重新定義它們。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