您的服务器不支持处理此类型图像所需的GD功能 [英] Your server does not support the GD function required to process this type of image.Ci

查看:246
本文介绍了您的服务器不支持处理此类型图像所需的GD功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做过图片上传,在CI中调整过多次。相同的代码在一个页面中工作,但不在其他页面中工作。当我显示错误它说:您的服务器不支持处理此类型的图像所需的GD功能。上传图片的代码是... \

I had done image upload,resized many times in CI. The same code is working in one page but not working in other page . when i display the error it says" Your server does not support the GD function required to process this type of image." The code to upload image is ...\

 function do_upload() {

        $original_path = './uploads/activity_images/original';
        $resized_path = './uploads/activity_images/resized';
        $thumbs_path = './uploads/activity_images/thumb';
        $this->load->library('image_lib');

        $config = array(
            'allowed_types' => 'jpg|jpeg|gif|png', //only accept these file types
            'max_size' => 2048, //2MB max
            'upload_path' => $original_path //upload directory    
        );
        $this->load->library('upload', $config);
        $this->upload->do_upload();
        $image_data = $this->upload->data(); //upload the image
        $image1 = $image_data['file_name'];

        //your desired config for the resize() function
        $config = array(
            'source_image' => $image_data['full_path'], //path to the uploaded image
            'new_image' => $resized_path,
            'maintain_ratio' => true,
            'width' => 128,
            'height' => 128
        );
        $this->image_lib->initialize($config);
        $this->image_lib->resize();

        // for the Thumbnail image
        $config = array(
            'source_image' => $image_data['full_path'],
            'new_image' => $thumbs_path,
            'maintain_ratio' => true,
            'width' => 36,
            'height' => 36
        );
        //here is the second thumbnail, notice the call for the initialize() function again
        $this->image_lib->initialize($config);

        $this->image_lib->resize();
        //$this->image_lib->clear();
       echo  $this->image_lib->display_errors();
        var_dump(gd_info());
        die();
        return $image1;
    }

这是怎么回事? >

What is going on i can't understand..??

推荐答案

更改您的第一行:

$original_path = './uploads/activity_images/original';
$resized_path = './uploads/activity_images/resized';
$thumbs_path = './uploads/activity_images/thumb';
$this->load->library('image_lib');

到:

$config['image_library'] = 'gd2';
$original_path = './uploads/activity_images/original';
$resized_path = './uploads/activity_images/resized';
$thumbs_path = './uploads/activity_images/thumb';
$this->load->library('image_lib', $config);

这篇关于您的服务器不支持处理此类型图像所需的GD功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆