2014-01-26 46 views
0

我創建一個畫廊,使用codeignitor的每一件事情工作良好的圖像獲取上傳到那裏的願望路徑,但他們沒有出現,但他們的空間是。情況是這樣的: enter image description here大拇指沒有被顯示,即使圖像是在那裏的位置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在該文件夾中,我檢查了兩次。請確認錯誤。

+0

'$ this-> gallery_path'的值是多少? –

+0

$ this-> gallery_path = realpath(APPPATH)。 '/圖片'; –

+0

如果您的APPPATH包含base_url,則只刪除實際路徑。如果不是,則添加APPPATH的base_url。 –

回答

0

檢查圖像數組的'url'和'thumb_url'值。

同時在圖片thumb_url前添加您網站的基本網址。

+0

Array([0] => Array([url] => /Applications/MAMP/htdocs/showcase/application/images/Nature/10011_10200942508307089_684217831_n.jpg [thumb_url] =>/Applications/MAMP/htdocs/showcase/application/images/Nature/thumbs/10011_10200942508307089_684217831_n.jpg) [1] => Array/[應用/ MAMP/htdocs/showcase/application/images/sunset/Lion.jpg [thumb_url] =>/Applications/MAMP/htdocs/showcase/application/images/sunset/thumbs/Lion.jpg)) –

+0

我已經檢查過所有這些東西:/ –

0

我發現了錯誤實際上我沒有提供base_url()而不是它,我提供了realpath()。