图像上传正确,但没有调整图像大小: 这是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文件时也显示不支持)。
答案 0 :(得分:0)
通过在我的linux系统中安装GD库解决了问题。