2012-12-09 12 views
0

嗨,我有這個問題,我花4-5個小時尋找一個解決方案 這裏是我的代碼pyrocms(笨圖像庫)沒有創造拇指

$config = array(
      'upload_path' => './uploads/menus', 
      'allowed_types' => 'gif|jpg|jpeg|png', 
      'max_size' => '15000' 
     ); 
     $this->upload->initialize($config); 

     if ($this->upload->do_upload('image')) 
     { 

       $image_data = $this->upload->data(); 
       $thumbnail = 'thumb_' . $image_data['file_name']; 
       $thumb['image_library'] = 'gd2'; 
       $thumb['source_image'] = $image_data['full_path']; 
       $thumb['create_thumb'] = TRUE; 
       $thumb['thumb_marker'] = ''; 
       $thumb['new_image'] = $image_data['file_path'] . 'thumbs/' . $thumbnail; 
       $thumb['maintain_ratio'] = TRUE; 
       $thumb['width'] = 90; 
       $thumb['height'] = 90; 
       $this->load->library('image_lib', $thumb); 
       if($this->image_lib->resize()) 
       { 
        $img_details = array(
             'menu_id' => $this->db->insert_id(), 
             'full_path' => $image_data['full_path'], 
             'image_name' => $image_data['file_name'], 
             'thumb_path' => $thumb['new_image'], 
             'thumb_name' => $thumbnail, 
            ); 

        $upload = $this->db->insert('menus_images', $img_details); 
        return $upload; 
       } 
     } 

我使用PyroCMS,和我正在開發一個模塊,我需要上傳圖片。到目前爲止這麼好,我的問題是這樣的: 圖像上傳,調整大小檢查傳遞沒有問題,插入正確的數據在分貝,但在「拇指」文件夾不創建任何拇指。 如果您有任何建議,請給我一些幫助。 謝謝!

+0

順便說一句,我忘了說,我檢查文件夾的權限,他們都設置正確 – lesandru

回答

1

您可以使用Stream API來開發您的模塊。順便說一句,我使用PyroCMS,我剛剛完成了一個新的模塊,我使用codeigniter lib來創建沒有問題的拇指。 你的代碼semms正確的,我可以建議你唯一要做的就是在image_lib的加載和初始化這樣分開:

$this->load->library('image_lib'); 

$thumbnail = 'thumb_' . $image_data['file_name']; 
$thumb['image_library'] = 'gd2'; 
$thumb['source_image'] = $image_data['full_path']; 
$thumb['create_thumb'] = TRUE; 
$thumb['thumb_marker'] = ''; 
$thumb['new_image'] = $image_data['file_path'] . 'thumbs/' . $thumbnail; 
$thumb['maintain_ratio'] = TRUE; 
$thumb['width'] = 90; 
$thumb['height'] = 90; 

$this->image_lib->initialize($thumb); 

這樣,你不應該有任何問題。 如果它不起作用嘗試分離主圖像和拇指,您可以創建第一個圖像,然後用兩個separata函數創建拇指。

+0

男人你是一個傳奇。你是個傳奇人物,非常感謝你的幫助。 – lesandru

+0

如果我能給你10個ups,我會的。再次感謝 – lesandru

+0

林間空地幫助你:)請接受答案,當你可以:) –