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

[HELP] ci中图片出不来

[复制链接]
发表于 2013-11-27 21:37:12 | 显示全部楼层 |阅读模式
路径都是对的,图片就是出不来
发表于 2013-11-28 14:40:38 | 显示全部楼层
贴代码。
 楼主| 发表于 2013-11-28 17:24:08 | 显示全部楼层
举个简单的例子:
hello.php:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Hello extends CI_Controller{
    public function index(){
        $this->load->view("hello.html");
    }
}

hello.html:
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <img src="<?php echo base_url("appplication/views/ecshop_logo.gif"); ?>" alt="">
    <p>aaaaaaaaaaa</p>
</body>
</html>
访问loalhost/citest/hello/index就出来aaaaaaaa,上面那张图片出不来,我开firebug看,他说载入指定的url失败

发表于 2013-11-28 18:03:48 | 显示全部楼层
图片不要放到 application 目录下,建议放到 index.php 所在目录。
另外要看下 base_url() 生成的 URL 是不是正确,不正确要去 config.php 里设置下 base_url
发表于 2013-11-29 01:31:39 | 显示全部楼层
Hex 发表于 2013-11-28 18:03
图片不要放到 application 目录下,建议放到 index.php 所在目录。
另外要看下 base_url() 生成的 URL 是不 ...

我觉得在文档里的url那节加上静态资源单起一个目录的提示吧。。。
 楼主| 发表于 2013-11-29 05:23:22 | 显示全部楼层
照你说的,果然成功了,为什么不能放在application目录下呢?
发表于 2013-11-29 10:10:39 | 显示全部楼层
dren_a 发表于 2013-11-29 01:31
我觉得在文档里的url那节加上静态资源单起一个目录的提示吧。。。

感谢建议。我看看文档如何改善下。
发表于 2013-11-29 10:11:42 | 显示全部楼层
低头感伤 发表于 2013-11-29 05:23
照你说的,果然成功了,为什么不能放在application目录下呢?

application 目录下只能放 .php 文件。

发表于 2013-11-29 16:22:07 | 显示全部楼层
低头感伤 发表于 2013-11-29 05:23
照你说的,果然成功了,为什么不能放在application目录下呢?

因为application目录下的.htaccess写着deny from all

本版积分规则