tegarkurniawan

upload file

Dec 9th, 2014
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. public function proses_tambah_user(){
  2.  
  3. $config['upload_path'] = "./assets/images/";
  4. $config['allowed_types'] = 'gif|jpg|png|jpeg';
  5. $config['max_size'] = '2000';
  6. $config['max_width'] = '2000';
  7. $config['max_height'] = '2000';
  8. $this->load->library('upload', $config);
  9.  
  10. if ($this->upload->do_upload("foto")) {
  11. $data = $this->upload->data();
  12.  
  13. $source = "./assets/images/".$data['file_name'] ;
  14. $nama=$data['file_name'] ;
  15.  
  16.  
  17.  
  18. chmod($source, 0777) ;
  19.  
  20.  
  21. $this->load->library('image_lib') ;
  22. $img['image_library'] = 'GD2';
  23. $img['create_thumb'] = TRUE;
  24. $img['maintain_ratio']= TRUE;
  25.  
  26.  
  27.  
  28. $data = array(
  29.  
  30. "username" =>$this->input->post('username'),
  31. "password" =>md5($this->input->post('password')),
  32. "password_view" =>$this->input->post('password'),
  33. "email" =>$this->input->post('email'),
  34. "foto" =>$nama,
  35. );
  36. $this->m_Backend->tambah_data_user($data);
  37. redirect(site_url('Backend/user'));
  38. }else{
  39. echo "Failed!" ;
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment