Codeigniter image resize?

前端 未结 6 1431
故里飘歌
故里飘歌 2020-11-28 14:43

I have problem with image class in CI?

This is example

On controller:

$this->load->library( array(\'image_lib\') );

O

6条回答
  •  猫巷女王i
    2020-11-28 15:15

    function uploadimage()
        {
    
            $file_name                  = $this->input->post('fileName');
            $imageName                  = 'set_'.file_name($_FILES["file"]['name'],date('Ymd_his'));
            $config['image_library']    = 'gd2';
            $config['source_image']     = $imageName;
            $config['create_thumb']     = TRUE;
            $config['maintain_ratio']   = TRUE;
            $config['master_dim']       = 'width'; 
            upload_resize('file','settings', $imageName );
            $config['width']            = 200;
            $config['height']           = 62;
    
            $this->load->library('image_lib', $config);
            $this->image_lib->initialize($config);
            $this->image_lib->resize();
            $this->image_lib->clear();
            $json_data = array(
                    'error'     =>false,
                    'tmp_name'  =>$file_name,
                    'file_name' =>base_url().'assets/uploads/settings/'.$imageName.'?dummy='.rand(0,1000),
                    'file_path' =>$imageName
            );
    
            echo json_encode($json_data);
        }
    }
    

    this code upload image to folder before save to table.

提交回复
热议问题