douza19870617 2013-12-28 18:53
浏览 25
已采纳

服务器不显示图像

I've got an image, let's say in http://localhost/myapp/uploads/image.jpg.

And i've got a script that pulls this image for display on the home page, like so:

<img src="<? echo base_url().'uploads/.$filename ; ?>

That eventually puts out the following HTML:

<img src="http://localhost/myapp/uploads/image.jpg">

Now, when I access the folder in windows explorer, I can clearly see the image there.

However, when trying to show it using the link as specified above - it throws a 404.

A few things:

  1. My base_url() is set correctly.
  2. The apache error log doesn't show the action.
  3. The Apache Access log, however, shows the the following: "GET /myapp/uploads/image.jpg HTTP/1.1 " 404 1175

I'm confused as to what exactly went wrong in here.

  • 写回答

4条回答 默认 最新

  • dsnd7200 2014-01-04 11:00
    关注

    So - The soultion proves to be simpler than i thought.

    I opened up my .htaccess file (which cancels out the use of index.php) and changed:

    RewriteEngine On
    RewriteCond $1 !^(index\.php|images|robots\.txt)
    RewriteRule ^(.*)$ index.php/$1 [L]
    

    To:

    RewriteEngine On
    RewriteCond $1 !^(index\.php|resources|robots\.txt)
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L,QSA]
    Options -Indexes
    

    Which solves the problem.

    Apparently I used a .htaccess that prevents images from being shown....if somebody could explain exactly what these several lines of code do - I'd be grateful.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 路易威登官网 里边的参数逆向
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程