0

此功能不能上传超过 2 张图片。如果尝试产生错误,

消息:未定义的索引:用户文件

看法
<input name="userfile[]" id="userfile" type="file" multiple="" />

控制器

 function do_upload() {

    $count = count($_FILES['userfile']['size']);

    foreach($_FILES as $key=>$value){
        for($n=0; $n<=$count-1; $n++) {
            $_FILES['userfile']['name']=$value['name'][$n];
            $_FILES['userfile']['type']    = $value['type'][$n];
            $_FILES['userfile']['tmp_name'] = $value['tmp_name'][$n];
            $_FILES['userfile']['error']       = $value['error'][$n];
            $_FILES['userfile']['size']    = $value['size'][$n];   

                $config['upload_path'] = './images/';
                $config['allowed_types'] = 'gif|jpg|png|jpeg';
                                    $config['max_size']       = 0;

            $this->load->library('upload', $config);
            $this->upload->do_upload();
            $data = $this->upload->data();
        }
    }   

}
4

1 回答 1

1

您绝对应该查看您的 php.ini 最大发布/上传大小。寻找如下值:

; Maximum allowed size for uploaded files.
upload_max_filesize = ##M

; Must be greater than or equal to upload_max_filesize
post_max_size = ##M

并将 # 更改为适合您的值

于 2012-10-12T14:56:31.297 回答