我創建一個畫廊,使用codeignitor的每一件事情工作良好的圖像獲取上傳到那裏的願望路徑,但他們沒有出現,但他們的空間是。情況是這樣的: 大拇指沒有被顯示,即使圖像是在那裏的位置codeignitor
這裏是我的模型代碼: 功能get_images() {
$query = $this->db->query("SELECT picAlbumName FROM picAlbum");
foreach($query->result() as $row)
{
$files = scandir($this->gallery_path . '/' . $row->picAlbumName);
$files = array_diff($files, array('.', '..', 'thumbs'));
foreach($files as $file){
$images [] = array (
'url' => $this->gallery_path. '/' . $row->picAlbumName . '/' . $file,
'thumb_url' => $this->gallery_path. '/' . $row->picAlbumName . '/' . 'thumbs/'. $file
);
}
}
print_r($images);
return $images;
}
控制器:
$data['images'] = $this->album_model->get_images();
$this->load->view('album_view' , $data);
觀點:
<?php if (isset($images) && count($images)):
foreach($images as $images): ?>
<div class="thumb">
<a href="<?php echo $images['url']; ?>">
<img src="<?php echo $images['thumb_url']; ?>" />
</a>
</div>
<?php endforeach; else: ?>
<div id="blank_gallery">Please upload an image</div>
<?php endif; ?>
圖片是th在該文件夾中,我檢查了兩次。請確認錯誤。
'$ this-> gallery_path'的值是多少? –
$ this-> gallery_path = realpath(APPPATH)。 '/圖片'; –
如果您的APPPATH包含base_url,則只刪除實際路徑。如果不是,則添加APPPATH的base_url。 –