0

这是代码:

for ($i=0; $i<$total_count_of_files; $i++)
                {
                    $_FILES['userfile']['name'] = $_FILES['pics']['name'][$i];
                    $_FILES['userfile']['type'] = $_FILES['pics']['type'][$i];
                    $_FILES['userfile']['tmp_name'] = $_FILES['pics']['tmp_name'][$i];
                    $_FILES['userfile']['error'] = $_FILES['pics']['error'][$i];
                    $_FILES['userfile']['size'] = $_FILES['pics']['size'][$i];

                    $config['upload_path'] = './uploads/gallery/';
                    $config['allowed_types'] = 'jpg|jpeg|gif|png';
                    $config['max_size'] = '0';
                    $config['encrypt_name'] = TRUE;

                    $this->upload->initialize($config);

                    if($this->upload->do_upload())
                    {
                        $pic = $this->upload->data();

                        // Thumbnail
                        $config1['image_library'] = 'gd2';
                        $config1['source_image'] = $pic['full_path'];
                        $config1['create_thumb'] = TRUE;
                        $config1['maintain_ratio'] = FALSE;
                        $config1['width'] = 180;
                        $config1['height'] = 113;

                        $this->load->library('image_lib', $config1);
                        $this->image_lib->resize();
                        // Thumbnail ends

                        $count_imgs += 1;
                        $this->galleries_model->add_image($pic['file_name'], $pic['image_width'], $pic['image_height'], $gallery_id);
                    }
                }

该代码工作正常,只是缩略图创建有一个问题,它只制作一个拇指(上传的第一个图像)然后不创建(但继续上传其他原始图像)。可能是什么问题呢?

谢谢你。

4

1 回答 1

0

我认为您必须在每次创建图像后清除图像库类。

$this->image_lib->resize();
$this->image_lib->clear();
于 2012-08-11T01:19:11.533 回答