嘿伙计们,我有这个问题,我花了 4-5 个小时寻找解决方案这是我的代码
$config = array(
'upload_path' => './uploads/menus',
'allowed_types' => 'gif|jpg|jpeg|png',
'max_size' => '15000'
);
$this->upload->initialize($config);
if ($this->upload->do_upload('image'))
{
$image_data = $this->upload->data();
$thumbnail = 'thumb_' . $image_data['file_name'];
$thumb['image_library'] = 'gd2';
$thumb['source_image'] = $image_data['full_path'];
$thumb['create_thumb'] = TRUE;
$thumb['thumb_marker'] = '';
$thumb['new_image'] = $image_data['file_path'] . 'thumbs/' . $thumbnail;
$thumb['maintain_ratio'] = TRUE;
$thumb['width'] = 90;
$thumb['height'] = 90;
$this->load->library('image_lib', $thumb);
if($this->image_lib->resize())
{
$img_details = array(
'menu_id' => $this->db->insert_id(),
'full_path' => $image_data['full_path'],
'image_name' => $image_data['file_name'],
'thumb_path' => $thumb['new_image'],
'thumb_name' => $thumbnail,
);
$upload = $this->db->insert('menus_images', $img_details);
return $upload;
}
}
我正在使用 PyroCMS,我正在开发一个需要上传图像的模块。到目前为止一切顺利,我的问题是:图像被上传,调整大小检查没有问题通过,在 db 中插入正确的数据,但是在“thumbs”文件夹中没有创建任何拇指。如果您有任何建议,请给我一些帮助。谢谢!