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

[已解决] 关于处理图片时的权限问题

[复制链接]
发表于 2011-12-5 19:08:16 | 显示全部楼层 |阅读模式
我做图片缩略图的时候提示The path to the image is not correct.

Your server does not support the GD function required to process this type of image.

百度翻译了一下是:图像的路径是不正确的,你的服务器不支持的功能需要处理这类图像。

我在控制器里的代码是:public function Welcome()
        {
           
                   parent::__construct();
                   $this->load->helper('url');
                  
      
        }
       
        public function index(){
                $this->load->helper('url');
                $config['image_library'] = 'gd2';
$config['source_image'] = '/images/2.jpg';
$config['create_thumb'] = TRUE;
$config['maintain_ratio'] = TRUE;
$config['width'] = 50;
$config['height'] = 50;
$this->load->library('image_lib', $config);

if($this->image_lib->resize()){
echo "ok";
$this->load->view('file');}
else{
          echo $this->image_lib->display_errors();

        $this->load->view('file');
}
               
               
        }
images文件是在根目录下的啊,2.jpg也存在。是不是我没有开启images文件夹的可写权限啊?怎么开启呢?

求解答
 楼主| 发表于 2011-12-5 19:08:50 | 显示全部楼层
在线急等啊
发表于 2011-12-5 20:00:05 | 显示全部楼层
本帖最后由 qi_ruo 于 2011-12-5 20:02 编辑

$config['source_image'] = '/images/2.jpg';估计是这个问题,你改成'images/2.jpg' 试试(相对于网站根目录)或改成绝对路径/var/www/......什么的
 楼主| 发表于 2011-12-5 20:21:11 | 显示全部楼层
qi_ruo 发表于 2011-12-5 20:00
$config['source_image'] = '/images/2.jpg';估计是这个问题,你改成'images/2.jpg' 试试(相对于网站根目 ...

没用的,我试过了。而且我让一个朋友复制到他那里去试试,结果跟我一样,是不是代码写错了?
 楼主| 发表于 2011-12-7 21:47:05 | 显示全部楼层
问题搞定了,问题就是出在路径上
发表于 2012-2-25 15:09:32 | 显示全部楼层
需要 类似于 ./images/aaa.jpg    其中./为根目录
发表于 2012-8-17 17:56:12 | 显示全部楼层
PHP CI框架 CodeIgnite交流 256269683
发表于 2012-8-17 18:05:58 | 显示全部楼层
256269683 PHP CI框架 CodeIgnite交流群
发表于 2012-8-17 18:06:13 | 显示全部楼层
256269683 PHP CI框架 CodeIgnite交流群

本版积分规则