【问题标题】:codeigniter image library does it really work?codeigniter 图像库真的有用吗?
【发布时间】:2018-10-23 19:37:15
【问题描述】:

图片上传正确,但图片大小未调整: 这是html:

<form action="<?php echo base_url();?>index.php/welcome/image_upload" method="post" enctype="multipart/form-data">

        <input type="file" name="image">
        <input type="submit" name="send" value="send">
    </form>

这里是控制器:

public function image_upload()
{
    $config['upload_path']       = './upload';
    $config['allowed_types']     = 'jpg|png|jpeg';

    $config['max_size']          = 2000;
    $config['min_size']          = 100;

    $config['max_width']         = 1024;
    $config['min_width']         = 400;

    $config['max_height']        = 1000;
    $config['min_height']        = 400;

    $config['encrypt_name']     = TRUE;

    $this->load->library('upload');

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

    if ( ! $this->upload->do_upload("image"))
    {
       echo $this->upload->display_errors();
    }else{
        $data[] = $this->upload->data();

        $config['image_library'] = 'gd2';
        $config['source_image'] = $data[0]["full_path"];
        $config['create_thumb'] = TRUE;
        $config['maintain_ratio'] = TRUE;
        $config['width']         = 600;
        $config['height']       = 800;

        $this->load->library('image_lib');
        $this->image_lib->initialize($config);
        $this->image_lib->resize();

        echo $this->image_lib->display_errors();
    }

输出: 您的服务器不支持处理此类图像所需的 GD 功能。 不支持 JPG 图片。(当我上传 jpg 文件时说,当上传 png 文件时也说不支持)。

【问题讨论】:

    标签: php codeigniter-3 gd


    【解决方案1】:

    通过在我的linux系统中安装GD库解决了这个问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-18
      • 2021-07-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多