大虾能帮我看看那里有问题了???在线等
本帖最后由 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 />";
}
}
}
这样运行以后 我看不到缩略图呢? 我才开始学习,5555 楼主,你的路径搞错了,system 目录下是不可能有非 PHP 文件的。
所有路径都是相对于 index.php 所在路径。 我在里面建了一个image文件,里面放图片了 目前没有搞清楚楼主的系统。
/image/MA-FLY-040.jpg 你这个路径指的是 Web 根目录吗?如果这里是 http://domain/image/MA-FLY-040.jpg 的话,那楼主应该在 $config['source_image'] 中写文件系统路径,也就是 C:/xxxx/xxx 这样的路径。 本帖最后由 sindy 于 2009-6-25 12:51 编辑
我在system\application\下建的 image文件架
所以$config['source_image'] = '/image/MA-FLY-040.jpg'; 首先,你这样放置目录是错误的,不要在 system 下面创建任何非 PHP 文件。
放到和 index.php 同级的目录去。
然后,source_image 使用相对路径 './images/xxxx.jpg'
最后,请楼主尽量在 CI 中使用相对的“文件系统”路径,而 URL 使用绝对路径! 同意楼上观点
页:
[1]