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 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 再不同版本的系统上,TCP传输速度不一致
  • ¥15 高德地图2.0 版本点聚合中Marker的位置无法实时更新,如何解决呢?
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题