2015-06-19 42 views
0

我想縮略圖保存的目錄,但它不工作。我可以保存原始圖像並將信息保存到數據庫,但出於某種原因,縮略圖不會保存到我創建的拇指目錄中。該目錄具有讀/寫訪問權限。我也會注意到我正在使用Dropzone.js。笨3上傳不保存拇指目錄

這裏是我的部分代碼:

if (! $this->upload->do_upload('file')) 
{ 
    //upload failed, echo back negative response to dropzone.js 

    } 
    else 
    { 
      //upload success, upload file(s) 
      $image_data = $this->upload->data(); 

      $img_config['source_image'] = '/uploads/videos/'.$image_data['file_name']; 
      $img_config['new_image']  = '/uploads/videos/thumbs/'.$image_data['file_name']; 
      $img_config['create_thumb'] = TRUE; 
      $img_config['maintain_ratio'] = TRUE; 
      $img_config['width'] = 251; 
      $img_config['height'] = 180; 

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

      $this->image_lib->resize(); 

      $file = array(
       'user_id'  => $this->my_auth->logged_in(), 
       'img_name' => $image_data['raw_name'], 
       'thumb_name' => $image_data['raw_name'].'_thumb', 
       'ext'   => $image_data['file_ext'], 
       'upload_date' => time() 
      ); 

      $this->upload_model->add_image($file);    

      $data['img_success'] = '<div class="alert alert-success" id="imgSuccess">Your image <strong>' . $image_data['file_name'] . '</strong> was successfully uploaded!</div>'; 

      $this->load->view('templates/frontend/front_header', $data); 
      $this->load->view('templates/frontend/front_navbar'); 
      $this->load->view('frontend/upload_images', $data); 
      $this->load->view('templates/frontend/front_footer', $data);       
     }  

我能夠成功地保存了原始圖像,只是沒有縮略圖。任何人都可以在這裏看到什麼錯

回答

0

我說這個我__construct

$this->original_path = realpath(APPPATH.'../uploads/images'); 
$this->thumbs_path = realpath(APPPATH.'../uploads/images/thumbs'); 

,並改變了source_imagenew_image CONFIGS:

$img_config['source_image'] = $image_data['full_path']; 
$img_config['new_image']  = $this->thumbs_path; 

這似乎已經固定它。

+0

如果這是答案,請點擊左側的刻度圖標自行接受,所以它會變綠。謝謝! – halfer