Php Codeigniter 2.1-多文件上传不起作用

Php Codeigniter 2.1-多文件上传不起作用,php,codeigniter,Php,Codeigniter,我有点问题。当我选择上传一张图片时,这个功能就起作用了。但对于多个图像,它不起作用,我得到了错误 您没有选择要上载的文件 如果用户输入正确的代码,更多图像上传的字段将通过JS创建。如果未输入代码或代码错误,则使用原始输入选择文件。 有什么问题吗 控制器功能: function img_upload($folder) { $this->path = './public/img/' . $folder; $imgs = array();

我有点问题。当我选择上传一张图片时,这个功能就起作用了。但对于多个图像,它不起作用,我得到了错误

您没有选择要上载的文件

如果用户输入正确的代码,更多图像上传的字段将通过JS创建。如果未输入代码或代码错误,则使用原始输入选择文件。 有什么问题吗

控制器功能:

function img_upload($folder) {
        $this->path = './public/img/' . $folder;
        $imgs = array();        
        $config = array(
            'allowed_types' => 'jpg|jpeg|png|gif',
            'upload_path' => $this->path
        );
        $CI = &get_instance();
        $CI->load->library('upload', $config);

        foreach ($_FILES as $key => $value) {

            if (!$CI->upload->do_upload($key)) {
                return $error = implode(',',array('error' => $CI->upload->display_errors()));
            } else {
                $q = $CI->upload->data();
                $config['image_library'] = 'gd2';
                $config['source_image'] = $this->path . '/' . $q['file_name'];
                $config['new_image'] = $this->path . '/thumbs';
                $config['create_thumb'] = FALSE;
                $config['maintain_ratio'] = TRUE;
                $config['width'] = 128;
                $config['height'] = 128;

                $CI->load->library('image_lib');
                $CI->image_lib->clear();
                $CI->image_lib->initialize($config); 
                $CI->image_lib->resize();                       
                array_push($imgs, $q['file_name']);
            }      
        }

        if(empty($imgs)){
            return FALSE;
        } else {
            return implode(',', $imgs);
        }
    }
用于选择文件的HTML的一部分:

<label for="image">Slika</label><input type="file" name="userfile" id="image" />
用于添加新字段的JS:

code.on('focusout', function(){
       if(!$(this).val())
           {
              $('label[for^=image_paid], input[id^=image_paid], input[name=time]').remove();                              
           }
       if(!$('#image4').length > 0)
           {$.ajax({
           type: 'POST', 
           url: '<?php echo base_url() ?>global_info/gi_get_ad_payment_code',
           data: 'code=' + code.val(),
           success: function(data){
             for(i = 1; i<=4; i++)
            {
               $('#image').after('<label for="image' + i +'">Slika</label><input type="file" name="userfile" id="image' + i +'" />');
            }  
            code.after('<input type="hidden" name="time" value="'+ data +'" />');            
            code.after('<input type="hidden" name="paid" value="1" />');            
           },
           error: function(){
               alert('nije uspeh');
           }
        }); /* KRAJ NA AJAX */
        };/* KRAJ NA IF */        
        });

如果你不介意使用这个插件。我已经用过很多次了