我想知道我的代码出了什么问题,图像没有像它想象的那样显示出来。什么也没出现。只是空白。我希望会出现一个图像。
视图/ editgalleries.php
<?php foreach ($pictures as $pictures_item): ?>
<td><br><img src="<?php echo base_url('../uploads/'); ?><?php echo $pictures_item['galleries_picture_name']; ?>" height="300" width="200"></td>
<?php endforeach; ?>
Cpages.php
public function edit_galleries_picture()
{
$gallery_id = $this->uri->segment(3);
$data['pictures'] = $this->Mpages->call_gallery_pictures($gallery_id);
$this->load->view('editgalleries', $data);
}
模型/ Mpages.php
public function call_gallery_pictures($gallery_id)
{
$this->db->where('gallery_id', $gallery_id);
$query = $this->db->get('galleries_pictures');
return $query->result_array();
}
答案 0 :(得分:2)
在根目录中设置uploads文件夹并尝试此代码
<?php echo base_url('uploads/'.$pictures_item['galleries_picture_name']); ?>
答案 1 :(得分:0)
<img src="<?php echo base_url('uploads'); ?>/<?php echo $pictures_item['galleries_picture_name']; ?>" height="300" width="200">
请注意'base_url('../uploads/')'
,
'../'
部分不是必需的,因为它会提供您的主机名。