2015-12-26 120 views
0

當|我插入它顯示錯誤的圖像圖像插入不工作

無效的偏移

這是我的控制器。

我已經從我的項目中的其他頁面複製它,它在那裏工作 - 但在新頁面上顯示錯誤。

$config['upload_path'] = './assets/upload/'; /* NB! create this dir! */ 
    $config['allowed_types'] = 'gif|jpg|png|bmp|jpeg'; 
    $config['max_size'] = '2048'; 
    $config['max_width'] = '5000'; 
    $config['max_height'] = '5000'; 
    /* Load the upload library */ 
    $this->load->library('upload', $config); 

    /* Create the config for image library */ 
    /* (pretty self-explanatory) */ 
    $configThumb = array(); 
    $configThumb['image_library'] = 'gd2'; 
    $configThumb['source_image'] = ''; 
    $configThumb['create_thumb'] = TRUE; 
    $configThumb['maintain_ratio'] = TRUE; 
    /* Set the height and width or thumbs */ 
    /* Do not worry - CI is pretty smart in resizing */ 
    /* It will create the largest thumb that can fit in those dimensions */ 
    /* Thumbs will be saved in same upload dir but with a _thumb suffix */ 
    /* e.g. 'image.jpg' thumb would be called 'image_thumb.jpg' */ 
    $configThumb['width'] = 140; 
    $configThumb['height'] = 210; 
    /* Load the image library */ 
    $this->load->library('image_lib'); 
$file=array(); 
$file_thumb=array(); 
      /* We have 5 files to upload 
    * If you want more - change the 6 below as needed 
    */ 
    for($i = 1; $i < 3; $i++) { 
    /* Handle the file upload */ 
    $upload = $this->upload->do_upload('image'.$i); 
    /* File failed to upload - continue */ 
    if($upload === FALSE) continue; 
    /* Get the data about the file */ 
    $data = $this->upload->data(); 
    $file[$i] = $data['file_name']; 
    $file_thumb[$i] = $data['raw_name'].'_thumb'.$data['file_ext']; 


    $uploadedFiles[$i] = $data; 
    /* If the file is an image - create a thumbnail */ 
    if($data['is_image'] == 1) { 
     $configThumb['source_image'] = $data['full_path']; 
     $this->image_lib->initialize($configThumb); 
     $this->image_lib->resize(); 
    } 
    } 

///=============upload end here==================//// 
    echo $file['1']; 
    exit; 
+0

安置自己的完整的錯誤信息,包括您的形式! – Saty

+0

一個PHP錯誤遇到 嚴重性:注意 消息:未定義抵消:1個 文件名:控制器/ biaso.php 行號:105 –

+0

Bias Pic:

回答

0

您已設置了一些圖片大拇指

$configThumb = array(); 
$configThumb['image_library'] = 'gd2'; 
$configThumb['source_image'] = ''; 
$configThumb['create_thumb'] = TRUE; 
$configThumb['maintain_ratio'] = TRUE; 
$configThumb['width'] = 140; 
$configThumb['height'] = 210; 

好篦。和你加載庫以及$this->load->library('image_lib');

所以這個設置如何獲得配置到庫。


添加這也

$this->load->library('image_lib', $configThumb); # configuration variable 

閱讀本

Image Manipulation Class

+0

如果我的回答很有幫助,接受它。謝謝 –