0

当控制器从视图接收文件图像时,我想调整图像大小这是我的代码

$this->load->library('upload');
$config[''image_library] = GD2;             
$config['upload_path'] = $path ;
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '1024';
$config['max_width']  = '1024';
$config['max_height']  = '768';
$config['encrypt_name'] = 'true';
$config['width'] = 200;
$config['height'] = 200;
$this->upload->initialize($config);
$this->upload->resize();
if(!$this->upload->resize()){
   echo $this->upload->display_error();
}

我的错误是

Call to undefined method CI_Upload::resize()

谢谢

4

1 回答 1

0

错误:$config[''image_library] = GD2;

$config['image_library'] = GD2;

加载图像处理类:

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

错误:$this->upload->resize(); if(!$this->upload->resize()){ echo $this->upload->display_error(); }

if( !$this->upload->do_upload() ){
    print_r( $this->upload->display_errors() );
}else{
    $this->image_lib->resize();
}
于 2013-09-04T08:41:49.083 回答