douke9379 2018-07-06 13:02
浏览 39
已采纳

如何在codeigniter中显示/显示图像?

I am trying to display the images of my Houses from the folder but it shows the error like this

http://localhost/jageerx/assets/images/House/assets/images/House28278954_957081961107785_391331158313648576_n.jpg

404 (Not Found)

My code is below

<?php
$PropertyType = "";
$image = "";
if($data != null)
{
foreach($data as $key=>$value)
{
    $PropertyType = $value['PropertyType'];
    $image=$value['HouseImage1'];
}
}
?>

the front-end code is this

 <img src="<?php echo base_url('assets/images/House/'. $image);?>" alt="tab1" class="img img-responsive"> 

folders hierarchy is mentioned below

This is the hierarchy of folders

this is the model function

public function SIngleHouseADD($houseID)
{
    $this->db->select('*');
    $this->db->from('housedetail');
    $this->db->where('HouseID', $houseID);
    //$qry = $qry->result_array();
    $query=$this->db->get();
    $resultArray = $query->result_array();
    return $resultArray;
    //return $qry;
}

this one is the controller

public function SingleProperty()
{
    //$HouseID = $_GET['id'];
    $this->load->model('SingleAddModel');
    $plots = $this->SingleAddModel->SIngleHouseADD($_GET['id']);
    $data = array();
    $data["data"] = $plots;
    $this->load->view('SinglePropertyDetail_view', $data);
}
  • 写回答

3条回答 默认 最新

  • doupang1917 2018-07-07 20:09
    关注

    In base_url() you are passing assets/images/House/ the same path in $image, so it is duplicating path, I'll suggest you to first echo the results then use them in html. And for your Image you can use:

    <img src="<?php echo base_url().$image;?>" alt="tab1" class="img img-responsive"> 
    

    OR

    <img src="assets/images/House/<?php echo $image;?>" alt="tab1" class="img img-responsive">
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 python怎么在已有视频文件后添加新帧
  • ¥20 虚幻UE引擎如何让多个同一个蓝图的NPC执行一样的动画,
  • ¥15 fluent里模拟降膜反应的UDF编写
  • ¥15 MYSQL 多表拼接link
  • ¥15 关于某款2.13寸墨水屏的问题
  • ¥15 obsidian的中文层级自动编号
  • ¥15 同一个网口一个电脑连接有网,另一个电脑连接没网
  • ¥15 神经网络模型一直不能上GPU
  • ¥15 pyqt怎么把滑块和输入框相互绑定,求解决!
  • ¥20 wpf datagrid单元闪烁效果失灵