Advertisement
Guest User

Untitled

a guest
Jan 11th, 2017
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. public function tambahanggota() {
  2. $this->load->library('upload');
  3. $nmfile = "file_".time();
  4. $config['upload_path'] = './assets/uploads/';
  5. $config['allowed_types'] = 'gif|jpg|png|jpeg|bmp';
  6. $config['max_size'] = '3072';
  7. $config['max_width'] = '5000';
  8. $config['max_height'] = '5000';
  9. $config['file_name'] = $nmfile;
  10.  
  11. $this->upload->initialize($config);
  12.  
  13. if($_FILES['filefoto']['tmp_name'])
  14. {
  15. if ($this->upload->do_upload('filefoto'))
  16. {
  17. $gbr = $this->upload->data();
  18. $data = array(
  19.  
  20. 'nm_gbr' =>$gbr['file_name']
  21. );
  22.  
  23. $res = $this->M_tambahdata->tambahdata("anggota",$data);
  24.  
  25. $config2['image_library'] = 'gd2';
  26. $config2['source_image'] = $this->upload->upload_path.$this->upload->file_name;
  27. $config2['new_image'] = './assets/hasil_resize/';
  28. $config2['maintain_ratio'] = TRUE;
  29. $config2['width'] = 100;
  30. $config2['height'] = 100;
  31. $this->load->library('image_lib',$config2);
  32.  
  33. if ($res>=1) {
  34.  
  35. echo "<script>alert('Data berhasil disimpan')</script>";
  36. echo "<script>window.location='".base_url()."dataanggota'</script>";
  37. }
  38.  
  39. else{
  40. $this->session->set_flashdata('pesan', 'Maaf, ulangi data gagal di inputkan.');
  41. redirect('dashboard/index');
  42. }
  43.  
  44. }
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement