我正在上传图像和创建拇指,一切工作正常,但每当我试图上传“webp图像”然后图像不上传,我得到以下错误您的服务器不支持处理这种类型的图像所需的GD功能这里是我目前的代码,我错了吗?
$imagePrefix = time();
$imagename = "img_".$imagePrefix.trim($_FILES['file']['name']);
$config['upload_path'] = 'uploads/nft/';
$config['allowed_types'] = 'jpg|jpeg|png|gif|PNG|JPG|JPEG|avif|webp';
$config['file_name'] = $imagename;
$this->load->library('upload',$config);
if($this->upload->do_upload('file'))
{
$uploadData = $this->upload->data();
$filename = $uploadData['file_name'];
$datas=$_POST;
$data = $this->upload->data();
$this->load->library('image_lib');
$config2['image_library'] = 'gd2';
$config2['source_image'] = $uploadData['full_path'];
$config2['new_image'] = './uploads/nft/thumb/'.$uploadData["raw_name"].$uploadData['file_ext'];
$config2['create_thumb'] = TRUE;
$config2['maintain_ratio'] = FALSE;
$config2['width'] = 350;
$config2['height'] = 350;
$this->image_lib->initialize($config2);
$this->image_lib->clear();
}
1条答案
按热度按时间hm2xizp91#
正常的文件上传方法用于调用另一个函数createThumbnail()调用
试试这个拇指函数创建你需要的图像尺寸