0

小さな問題があります。アップロード用のカスタム構成ファイルがあります。設定を再定義せずにロードしたい。

さて、私の構成は次のようになります。

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/');
}

$config['test] = $this->config->item('test'); の再定義を回避したい

これは不可能ですか?

4

3 に答える 3

0

http://ellislab.com/codeigniter/user-guide/libraries/config.html では、カスタム構成項目をロードする方法について説明しています。CI Web サイトが示唆するようにカスタム構成ファイルを作成し、そのカスタム構成ファイルを必要な場所にロードすることをお勧めします。

したがって、次のようなものが$this->config->load('custom_upload_settings', FALSE, TRUE);あり、そのファイルには、オーバーライドしたい設定があります。

// custom_upload_settings.php という名前の構成ファイルをロードし、「blog_settings」という名前のインデックスに割り当てます $this->config->load('custom_upload_settings', TRUE);

// custom_upload_settings 配列に含まれる site_name という名前の構成アイテムを取得します $site_name = $this->config->item('site_name', 'custom_upload_settings');

于 2013-04-22T14:50:55.740 に答える
0

何か不足しているかどうかはわかりませんが、コントローラーに行を入れないでください。これは事実上それを再宣言しませんか?

于 2013-04-22T14:46:08.647 に答える