2016-08-11 15 views
-2

私のコントローラは、親指のフォルダ名を除いて、この正常に動作します。例: 私の元のイメージ名はconverted.thumbとして保存されますが、だから私はイメージ名から_thumbを取り除きたいです。この問題を解決してください。Codeigniter image resize()サムネイル名は同じ名前でなければなりません

public function do_upload() { 
$config['upload_path'] = './uploads'; // uploaded file store here 
     $config['allowed_types'] = 'jpg|png|jpeg|gif'; 
     $config['max_size'] = ' 2097152'; 
     $this->load->library('upload', $config); 
     if ($this->upload->do_upload()) { 

      $data = $this->upload->data(); 

      //create copy of image 

      $configs['image_library'] = 'gd2'; 
      $configs['source_image'] = $data['full_path']; 
      $configs['new_image'] = 'uploads/thumbs/'; //resize image will save here 
      $configs['create_thumb'] = 'false'; 
      $configs['width'] = '250'; 
      $configs['height'] = '250'; 
      $this->load->library('image_lib', $configs); 
      $this->image_lib->resize(); 

      $image_name = $data['file_name']; 
      //$full_path = $data['full_path']; 
      $post = array(
       'product_name' => $image_name, 
       'product_path' => $configs['new_image'].$image_name 
      ); 

      $this->db->insert('project', $post); 
     } else { 
      echo $this->upload->display_errors(); 
     } 
    } 

} 
+0

[こちら](http://php.net/manual/en/function.rename.php)の方法でお試しください。 – Tpojka

答えて

0

なぜあなたはそのことを好まないのですか?それが何のためです。とにかくこれをやってください。

rename("<?php echo base_url()?>/uploads/thumbs/YOUR_FILE_NAME_THUMBS", "<?php echo base_url()?>/uploads/thumbs/YOUR_FILE_NAME"); 
0

あなた$configs配列にthumb_markerを試してみてください。

$configs['image_library'] = 'gd2'; 
    $configs['source_image'] = $data['full_path']; 
    $configs['new_image'] = 'uploads/thumbs/'; //resize image will save here 
    $configs['create_thumb'] = 'false'; 
    $configs['thumb_marker'] = ''; //Add this in your config array empty string 

「_thumb」は新しく作成されたファイルに追加されません。詳細についてはSourceをご覧ください。

関連する問題