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条)

报告相同问题?

悬赏问题

  • ¥50 关于#html5#的问题:H5页面用户手机返回的时候跳转到指定页面例如(语言-javascript)
  • ¥15 无法使用此凭据登录,因为你的域不可用,如何解决?(标签-Windows)
  • ¥15 yolov9的训练时间
  • ¥15 二叉树遍历没有报错但无法正常运行
  • ¥15 在linux系统下vscode运行robocup3d上场球员报错
  • ¥15 Python语言实验
  • ¥15 SAP HANA SQL 增加合计行
  • ¥20 用C#语言解决一个英文打字练习器,有偿
  • ¥15 srs-sip外部服务 webrtc支持H265格式
  • ¥15 在使用abaqus软件中,继承到assembly里的surfaces怎么使用python批量调动