【问题标题】:Enable to load image启用加载图像
【发布时间】:2017-05-04 13:07:23
【问题描述】:

我使用 codeigniter 框架来开发我的数据库,但是这个数据库中有一个小问题,即图像

图像显示如下:

但是当我右键单击它并单击在新选项卡中打开图像时,它会显示此错误

在新标签页中打开图片出错:

如果我在出现错误消息后再次刷新 url,现在图像打开,并且我启动此图像的主页也打开。 谁能告诉我这是什么问题,这是托管问题还是编码问题。 我正在使用此代码作为地点图像

<div class="col-md-4 col-md-offset-4 marg" style="margin-top:30px;">
        <?php
            if(count($siteinfos->photo)) {
                echo "<center>";
                echo "<img width='50' height='50' src=".base_url('uploads/images/'.$siteinfos->photo)." />";
                echo "</center>";
            }
        ?>
        <center><h4><?php echo $siteinfos->sname; ?></h4></center>
</div>

【问题讨论】:

  • 网址正确吗??
  • 图片位置不正确。确保您使用的是正确的图片路径。
  • 同意.. 图片位置不正确。放置您用于显示图像的代码。
  • 请查看网址webconsociates.com
  • 检查您的 URL 不会改变任何图像路径不正确的人。

标签: php html image codeigniter


【解决方案1】:

首先在控制器中加载 url 助手,从那里将数据传递到视图。像这样...

$this->load->helper('url'); 

那么只有你可以使用base_url()。用下面的代码替换你上面的代码..

<div class="col-md-4 col-md-offset-4 marg" style="margin-top:30px;">
<?php
    if(count($siteinfos->photo)) { ?>
       <center><img width='50' height='50' src=" <?php echo base_url('uploads/images/').$siteinfos->photo;?>" /></center>
 <?php    }
?>
<center><h4><?php echo $siteinfos->sname; ?></h4></center>
</div>

【讨论】:

  • 感谢您的回复,但我已将此代码放在我的数据库中,同样的问题现在右键单击后图像未显示。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-04-07
  • 1970-01-01
  • 2015-03-22
相关资源
最近更新 更多