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

大虾能帮我看看那里有问题了???在线等

[复制链接]
发表于 2009-6-25 12:23:30 | 显示全部楼层 |阅读模式
本帖最后由 sindy 于 2009-6-25 12:25 编辑

class Imageresize extends Controller {
        function index()
        {
                $this->load->library('Image_lib');
                $this->load->helper('array');
               
                $config['image_library'] = 'gd2';
                $config['source_image'] = '/image/MA-FLY-040.jpg';
                $config['create_thumb'] = TRUE;
                $config['maintain_ratio'] = TRUE;
                $config['width'] = 300;
                $config['height'] = 300;
               
                $this->load->library('image_lib', $config);

                if ( ! $this->image_lib->resize())
                {
                        echo $this->image_lib->display_errors('<p>', '</p>');
                }else
                {
                        echo "New Image <img src=\"../system/application/image/MA-FLY-040_thumb.jpg\" width=300 height=300 border=0 />";
                }
               
         }
        
}

这样运行以后 我看不到缩略图呢?
 楼主| 发表于 2009-6-25 12:23:57 | 显示全部楼层
我才开始学习,5555
发表于 2009-6-25 12:34:55 | 显示全部楼层
楼主,你的路径搞错了,system 目录下是不可能有非 PHP 文件的。

所有路径都是相对于 index.php 所在路径。
 楼主| 发表于 2009-6-25 12:36:50 | 显示全部楼层
我在里面建了一个image文件,里面放图片了
发表于 2009-6-25 12:36:51 | 显示全部楼层
目前没有搞清楚楼主的系统。

/image/MA-FLY-040.jpg 你这个路径指的是 Web 根目录吗?如果这里是 http://domain/image/MA-FLY-040.jpg 的话,那楼主应该在 $config['source_image'] 中写文件系统路径,也就是 C:/xxxx/xxx 这样的路径。
 楼主| 发表于 2009-6-25 12:40:06 | 显示全部楼层
本帖最后由 sindy 于 2009-6-25 12:51 编辑

我在system\application\下建的 image文件架
所以$config['source_image'] = '/image/MA-FLY-040.jpg';
发表于 2009-6-25 14:15:58 | 显示全部楼层
首先,你这样放置目录是错误的,不要在 system 下面创建任何非 PHP 文件。
放到和 index.php 同级的目录去。

然后,source_image 使用相对路径 './images/xxxx.jpg'

最后,请楼主尽量在 CI 中使用相对的“文件系统”路径,而 URL 使用绝对路径!
发表于 2009-6-28 17:32:45 | 显示全部楼层
同意楼上观点

本版积分规则