在Php中,两个图像不能同时创建缩略图

在Php中,两个图像不能同时创建缩略图,php,image,Php,Image,我正试图上传两个图像(“图像”和“封面图像”)同时与缩略图,但第二个代码/“图像” 未创建缩略图且未上载到文件夹,第一个代码/“coverimage”工作正常,但“image”未创建缩略图 我错在哪里?这是我的密码 //uploading image ( working fine and creating thumbnail) if( isset( $_FILES['CoverImage'] ) ){ if (file_exists($_FILES['CoverImage

我正试图上传两个图像(“图像”和“封面图像”)同时与缩略图,但第二个代码/“图像” 未创建缩略图且未上载到文件夹,第一个代码/“coverimage”工作正常,但“image”未创建缩略图 我错在哪里?这是我的密码

//uploading image ( working fine and creating thumbnail)
if( isset( $_FILES['CoverImage'] ) ){
            if (file_exists($_FILES['CoverImage']['tmp_name']) || is_uploaded_file($_FILES['CoverImage']['tmp_name'])) 
                {
                    $filenames = time() . uniqid(rand()) . $_FILES['CoverImage']['name'];
                    move_uploaded_file($_FILES["CoverImage"]["tmp_name"], "ShopCoverImage/" . $filenames);
                    $source_paths = $_SERVER['DOCUMENT_ROOT'] . '/ShopCoverImage/' . $filenames;
                    $target_paths = $_SERVER['DOCUMENT_ROOT'] . '/ShopCoverImage/thumb/';
                    $config_manips = array(
                        'image_library' => 'gd2',
                        'source_image' => $source_paths,
                        'new_image' => $target_paths,
                        'maintain_ratio' => FALSE,
                        'create_thumb' => TRUE,
                        'thumb_marker' => '',
                        'width' => 100,
                        'height' => 100
                    );
                    $this->load->library('image_lib', $config_manips);
                    if (!$this->image_lib->resize()) {
                        $error= $this->image_lib->display_errors();
                        return $error;
                    }
                    else
                    {
                        $saveArr['CoverImage'] = $filenames;
                    }
                    $this->image_lib->clear();
            } 
        }       

        //image uploading ( not creating thumbnail)
if( isset( $_FILES['image'] ) ){
if (file_exists($_FILES['image']['tmp_name']) || is_uploaded_file($_FILES['image']['tmp_name'])) 
                {
                    $filename = time();
                    $filename = time() . uniqid(rand()) . $_FILES['image']['name'];
                    move_uploaded_file($_FILES["image"]["tmp_name"], "Profile/" . $filename);
                    $source_path = $_SERVER['DOCUMENT_ROOT'] . '/Profile/' . $filename;
                    $target_path = $_SERVER['DOCUMENT_ROOT'] . '/Profile/thumb/';
                    $config_manip = array(
                        'image_library' => 'gd2',
                        'source_image' => $source_path,
                        'new_image' => $target_path,
                        'maintain_ratio' => FALSE,
                        'create_thumb' => TRUE,
                        'thumb_marker' => '',
                        'width' => 100,
                        'height' => 100
                    );
                    $this->load->library('image_lib', $config_manip);
                    if (!$this->image_lib->resize()) {
                         $error= $this->image_lib->display_errors();
                        return $error;
                    }
                    else
                    {
                        //$saveArr['image'] = $filename;
                    }
                    $this->image_lib->clear();
            } 
        }        

请使用以下代码:

从第二个上载图像代码中删除

 $this->load->library('image_lib', $config_manip);
并替换为以下代码

$this->image_lib->initialize($config_manip);

替换代码“无法加载请求的类:图像库”后显示以下错误