1
我有2个codeigniter函数用于图像上传和拇指创建。图像上传功能正常工作,但创建拇指功能不起作用。 我不知道我的功能中有什么错误?Codeigniter创建缩略图无法运作?
function uploaded() //upload function
{
$config['upload_path'] ='./uploads/';
$config['allowed_types'] ='jpeg|jpg|png|gif|bmp|JPEG|JPG|PNG|GIF|BMP|doc|docx|xlsx|txt';
$config['max_size'] = $this->config->item('max_upload_size');
$filename = strtolower($this->friendly($_FILES['image']['name']));
$config['file_name'] = $filename;
$config['remove_spaces'] = TRUE;
$this->load->library('upload', $config);
if ($this->upload->do_upload('image'))
{
$this->data['file'] = $this->upload->data();
$this->thumb($filename);
return true;
}
}
在代码中创建拇指功能
function thumb($filename)
{
$config['image_library'] = 'gd2';
$config['source_image'] = './uploads/'.$filename.'.jpg';
$config['create_thumb'] = TRUE;
$config['maintain_ratio'] = TRUE;
$config['width'] = 75;
$config['height'] = 50;
$config['new_image'] = './uploads/thumb/'.$filename;
$this->load->library('image_lib', $config);
$this->image_lib->initialize($config);
$this->image_lib->resize();
}
我试着不让工作.. –
什么是上传的路径从根文件夹 – Saty
为什么有这可能发生的几个原因。首先,将'$ this-> image_lib-> resize();'改为'if(!$ this-> image_lib-> resize()){die($ this-> image_lib-> display_errors());}'。这会告诉你是否有任何标准错误。请让我知道错误是什么(如果有的话)。如果没有人请你让我知道你使用的是什么操作系统。 –