私は過去に似たようなものだと思うものに出くわしました。
アップロードされたファイルをループしている場合、$config
ファイルごとに異なる場合は、反復ごとにアップロード クラスを初期化する必要があります。
$this->upload->initialize( $config );
ペーストビンなどのコード サンプルはありますか?
これは、ファイルの種類に応じて $config の変更を処理するために以前のプロジェクトで行ったことです。
if( $_FILES ) { $this->load->library('アップロード');
foreach ( $_FILES as $key => $value )
{
$file_type = ( $key == 'image' ) ? 'image' : 'document';
if( ! empty( $value['name'] ))
{
$config = array(
'upload_path' => './uploads/materials/' . strtolower($material['code']) . '/',
'allowed_types' => ($file_type == 'image') ? 'jpg|jpeg|png' : 'jpg|jpeg|png|pdf',
'max_size' => 1024 * 10,
'max_width' => 19200,
'max_height' => 12800,
'overwrite' => TRUE,
);
// ------------------------------------------------------------------------
// Here is the key idea: You need to initialize each time you change the $config
// ------------------------------------------------------------------------
$this->upload->initialize( $config );
if( $this->upload->do_upload( $key ))
{
//Success! Files are all uploaded.
$uploaded = $this->upload->data();
$data['file_data'] = array(
'parent_id' => $data['material']->id,
'filename' => $uploaded['file_name'],
'filename_original' => $uploaded['client_name'],
'type' => $file_type,
'location' => $config['upload_path'],
'description' => '',
);
// Add the file details to the database
$this->material->add_material_file( $data );
}
else
{
// ERROR! Something went wrong... alert the user.
$errors = $this->upload->display_errors();
$this->session->set_flashdata( 'flashError', $errors );
}
}
}
}