2009-07-23 12 views
2

il donne un écran vide:/il télécharge la première image, c'est très bien. qu'il appelle _create_thumbnail et il donne un écran vide à la ligne "$ this-> image_lib-> resize()":/Codeigniter photo thumb Créer et télécharger

une idée de ce qui peut être le problème?

Merci!

/** * ========================================= ========================= * Ajouter photo *
* pouce = 210px - 160px * original = 500px - 385px * */

function img_upload() 
{ 
    $config['upload_path'] = 'uploads/'; 
    $config['allowed_types'] = 'gif|jpg|jpeg|png'; 
    $config['max_size'] = '1000'; 
    $config['max_width'] = '1920'; 
    $config['max_height'] = '1280';  
    $config['width'] = 500; 
    $config['height'] = 385;     

    $this->load->library('upload', $config); 

    if(!$this->upload->do_upload()) echo $this->upload->display_errors(); 
    else { 

     $fInfo = $this->upload->data(); 
     $this->_create_thumbnail($fInfo['file_name']); 

     $data['uploadInfo'] = $fInfo; 
     $data['thumbnail_name'] = $fInfo['raw_name'] . '_thumb' . $fInfo['file_ext']; 

     // set view 
     $this->load->view('upload_success', $data); 
    } 
} 

function _create_thumbnail($fileName) 
{ 
    $config['image_library'] = 'gd2'; 
    $config['source_image'] = 'uploads/' . $fileName; 
    $config['create_thumb'] = TRUE; 
    $config['maintain_ratio'] = TRUE; 
    $config['width'] = 210; 
    $config['height'] = 160; 

    $this->load->library('image_lib', $config); 
    if(!$this->image_lib->resize()) echo $this->image_lib->display_errors(); 

} 

Répondre

1

Vérifiez vos accolades ici:

if(!$this->upload->do_upload()) echo $this->upload->display_errors(); else {

Il semble que vous mélangez des styles de syntaxe.

0

Essayez de retirer $fileName:

Au lieu de cela: $config['source_image'] = 'uploads/' . $fileName;

Utilisez ceci: $config['source_image'] = 'uploads/'

0

essayer cette

function _create_thumbnail($fileName) 
{ 
$this->load->library('image_lib'); 
     $config['image_library'] = 'gd2'; 
     $config['source_image'] = './uploads/' . $fileName;  
     $config['create_thumb'] = TRUE; 
     $config['maintain_ratio'] = TRUE; 
     $config['width'] = 210; 
     $config['height'] = 160; 
     $config['new_image'] = './uploads/'.$fileName; 

     $this->image_lib->initialize($config); 
     if(!$this->image_lib->resize()) echo 
$this->image_lib->display_errors(); 

}