【问题标题】:Can't get image to show in table using codeigniter无法使用codeigniter在表格中显示图像
【发布时间】:2020-03-16 14:07:32
【问题描述】:

我正在尝试在数据库中的表格中显示上传的图像。图片上传后保存在文件夹中,但不会显示图片。当我尝试在浏览器中打开图片 url 时,它显示 404 page not found.

image in table &error page

表格代码:

<td class="text-center"><img src="<?php echo base_url('image/product/'.$row->img_produk) ?>" width="64" /></td>

.htaccess:

RewriteEngine on
RewriteCond $1 !^(index\.php|assets|images|js|css|uploads|favicon.png)
RewriteCond %(REQUEST_FILENAME) !-f
RewriteCond %(REQUEST_FILENAME) !-d
RewriteRule ^(.*)$ ./index.php/$1 [L]

帮手:

$autoload['helper'] = array('url','form','html');

其他地方有问题吗?

【问题讨论】:

  • 渲染输出中src属性的实际内容是什么?
  • @CBroe 上传图片文件
  • 不是我的意思……但无论如何,如果您的屏幕截图显示的图像 URL 出现 404,那么要么该文件实际上不存在,要么您创建的路径错误。跨度>
  • 是的,我知道,这就是为什么我想知道这里出了什么问题,图片确实存在于 \htdocs\ehealth\image\product 文件夹中
  • @RadVolan 我想你在 baseurl() 之后错过了分号。

标签: php html .htaccess codeigniter


【解决方案1】:

.htaccess 文件中,使用“image”而不是“images”,因为它在代码(base_url('image/product/'.$row-&gt;img_produk) 中表示“image”。

RewriteEngine on
RewriteCond $1 !^(index\.php|assets|image|js|css|uploads|favicon.png)
RewriteCond %(REQUEST_FILENAME) !-f
RewriteCond %(REQUEST_FILENAME) !-d
RewriteRule ^(.*)$ ./index.php/$1 [L]

【讨论】:

    【解决方案2】:

    找到解决办法

    我编辑了 .htaccess 并且它可以工作

    RewriteEngine On
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php/$1 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-27
      • 2015-10-30
      相关资源
      最近更新 更多