Image_lib路径名错误,服务器不支持GD功能



我正在尝试上传图像然后调整其大小然后出现错误

"图像的路径不正确。您的服务器不支持处理此类图像所需的 GD 功能。但在$config['source_image'] = './production/images/'.$id_akun.'jpg';是我从"upload_path"=>"./生产/图像/"的路径,那么为什么我的路径不正确呢?这是我在控制器中的功能

                $id_akun=29;
                    $config = array(
                    'upload_path'  => "./production/images/",
                    'allowed_types' => "jpg",
                    'file_name' => $id_akun,
                    'overwrite' => true,
                    'max_size' => "2048",
                    'max_height' => "768",
                    'max_width' => "1024"
                    );
                    $this->upload->initialize($config);
                    if($this->upload->do_upload('userfile'))
                        {
                    $data = array(
                        'id' => $id_akun, 
                        'foto' => $this->upload->file_name
                        );
                        $this->User_model->upload($id_akun,$data);
                        $config['image_library'] = 'gd2';
                        $config['source_image'] = './production/images/'.$id_akun.'jpg';
                        $config['create_thumb'] = TRUE;
                        $config['maintain_ratio'] = TRUE;
                        $config['width']         = 220;
                        $config['height']       = 220;
                        $config['create_thumb'] = TRUE;
                        $this->image_lib->clear();
                        $this->image_lib->initialize($config);
                        $this->image_lib->resize();
                        $er=$this->image_lib->display_errors();
                        echo json_encode($er);
                        exit();  
                        }
GD

是一个处理图像处理的php扩展。您正在加载的库需要它才能工作。广东:http://php.net/manual/en/book.image.php

如果您无法直接访问服务器,那么您就有点不走运,除非您可以让托管服务提供商为您提供扩展程序。

如果你有服务器及其在Linux上,你可以使用包管理器来安装它(作为root用户,或使用sudo(

CentOS/RHEL 将是: yum install php-gd

乌班图: apt-get install php-gd

安装这些扩展后,您需要重新启动Web服务器以加载更新的php.ini文件。

除此之外,使用./开始您的路径可能没有帮助,请在开始时删除.。我还建议确保文件夹路径从 web-root 退出,并且您对文件夹设置了正确的权限,如果服务器是 linux 并且 Web 服务器拥有目录和文件的所有权,请确保您设置了正确的 chmod

最新更新