devasatrio

fungsi_input

Apr 25th, 2018
1,415
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.96 KB | None | 0 0
  1. function input(){
  2.         $config = array(
  3.                         'upload_path'=>'./uploads',
  4.                         'allowed_types'=>'jpg|png|jpeg',
  5.                         'max_size'=>2086
  6.                         );
  7.         $this->load->library('upload',$config);
  8.         $this->upload->do_upload('gambar');
  9.  
  10.         $finfo = $this->upload->data(
  11.         );
  12.         $nama_foto = $finfo['file_name'];
  13.  
  14.         $judul = $this->input->post('judul');
  15.         $tebal = $this->input->post('tebal');
  16.         $penerbit = $this->input->post('penerbit');
  17.        
  18.         //------------------------------------------
  19.  
  20.         $data_buku = array(
  21.                     'judul'=>$judul,
  22.                     'tebal'=>$tebal,
  23.                     'penerbit'=>$penerbit,
  24.                     'gambar'=>$nama_foto   
  25.                         );
  26.  
  27.         $config2 = array(
  28.                 'source_image'=>'uploads/'.$nama_foto,
  29.                 'image_library'=>'gd2',
  30.                 'new_image'=>'uploads/thumbnail',
  31.                 'maintain_ratio'=>true,
  32.                 'width'=>150,
  33.                 'height'=>200
  34.             );
  35.         $this->load->library('image_lib',$config2);
  36.         $this->image_lib->resize();
  37.         $this->M_buku->tambah_data($data_buku);
  38.  
  39.         redirect('C_buku');
  40.     }
Advertisement
Add Comment
Please, Sign In to add comment