用户
 找回密码
 入住 CI 中国社区
搜索
查看: 3235|回复: 4
收起左侧

[版本 2.x] CI2.0生成缩略图有问题,急求助,在线等。

[复制链接]
发表于 2011-12-7 15:50:29 | 显示全部楼层 |阅读模式
CI2.0生成缩略图有问题,急求助,在线等。
PHP复制代码
 
$config['image_library'] = 'gd2';
$config['source_image'] = './data/attachment/product/'.date("Ymd",time())."/".$imgname.".jpg";
$newimg_path = './data/attachment/product/'.date("Ymd",time())."/thumb";
 if(!file_exists($newimg_path))
 {
      @mkdir($newimg_path,0700);
}
$config['new_image']         = $newimg_path."/".$imgname.'.jpg';
$config['create_thumb']     = TRUE;
$config['maintain_ratio']     = TRUE;
$config['width']     = 100;
$config['height']     = 100;
$this->load->library('image_lib',$config);
if(!$this->image_lib->resize()){
      echo $this->image_lib->display_errors('<p>','<p>');
}
 
复制代码


生成的缩略图不成功,没有生成缩略图。但是图片已经上传好了。

 楼主| 发表于 2011-12-7 15:52:34 | 显示全部楼层
自己顶一个。代码是取自 CI2.0 缩略图的帮助手册。但是上传之后的图片没有生成缩略图。
 楼主| 发表于 2011-12-7 16:19:14 | 显示全部楼层
问题已解决。
PHP复制代码
 
$this->image_lib->initialize($config);
 
复制代码

不要忘了这一句。
发表于 2011-12-7 21:45:29 | 显示全部楼层
$config['source_image'] = './data/attachment/product/'.date("Ymd",time())."/".$imgname.".jpg";
这句是错误的吧?可以自动生成文件夹的么?
 楼主| 发表于 2011-12-9 10:16:34 | 显示全部楼层
╰↓①秒つ. 发表于 2011-12-7 21:45
$config['source_image'] = './data/attachment/product/'.date("Ymd",time())."/".$imgname.".jpg";
这句 ...

我在上面还有个函数 是用于处理用户上传文件的。里面对这个路径有做处理。如果不存在就会创建。
PHP复制代码
 
if(!file_exists($file_path))
{
   @mkdir($file_path);
}
 
复制代码

这个帖子写的是关于缩略图处理部分的,所以代码没有完全贴出。不好意思哈……

本版积分规则