Advertisement
melvin_pastebin

Upload dan Resize Image CI

Feb 17th, 2015
3,310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public function doinsertdata(){
  2.             //$id_kategori= $_POST['id_kategori'];
  3.             $judul = $_POST['judul'];
  4.             $cover = $_FILES['cover']['name'];
  5.             $tipebaru = explode(".",$cover);
  6.             $tipebaru2 = $tipebaru['1'];
  7.             $filebaru3 = str_replace(' ','_',$judul);
  8.             $file_input = 'cover';
  9.             $data_insert = array(
  10.                 //'kode_kategori' => $id_kategori,
  11.                 'judul_kategori' => $judul,
  12.                 'cover' => $filebaru3.'.'.$tipebaru2,
  13.                 );
  14.             $rby = $this->mymodel->Insertdata('kategori',$data_insert);
  15.             $image_source2 = base_url()."uploads/";
  16.        
  17.             //script upload start
  18.             $config['remove_spaces'] = TRUE;
  19.             $config['file_name'] = $filebaru3.'.'.$tipebaru2 ;
  20.             $config['upload_path'] = './uploads/';
  21.             $config['allowed_types'] = 'gif|jpg|png';
  22.             $config['max_size'] = '100000';
  23.             $config['max_width'] = '102400';
  24.             $config['max_height'] = '76800';
  25.             $this->load->library('upload', $config);
  26.             $this->upload->do_upload($file_input);
  27.             $this->upload->data();
  28.             //script upload end
  29.        
  30.             //script resize start
  31.             $config['image_library'] = 'gd2';
  32.             $config['source_image'] = ubah isinya sesuai dengan path dimana foto yg akan anda resize disimpan;
  33.             $config['create_thumb'] = TRUE;
  34.             $config['maintain_ratio'] = TRUE;
  35.             $config['width'] = 200;
  36.             $config['height'] = 200;
  37.             $this->load->library('image_lib',$config);
  38.             $this->image_lib->resize();
  39.             //script resize end
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement