Advertisement
Guest User

heres my piece of code in the controller

a guest
Mar 16th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. public function addNewUser() {
  2.  
  3.  
  4.  
  5. $this->load->helper(array('form','file','url'));
  6.  
  7. $config_image = array();
  8. $config_image['upload_path'] = './assets/uploads';
  9. $config_image['allowed_types'] = 'gif|jpg|png|jpeg';
  10. $config_image['max_size'] = '1024';
  11. $this->load->library('upload', $config_image);
  12.  
  13.  
  14. if (! $this->upload->do_upload('profilepic') ){
  15. $upload_data = $this->upload->data();
  16. $file_name = $upload_data['file_name'];
  17.  
  18. $data = array(
  19. 'success' => 1
  20. );
  21. }else{
  22. $upload_data = $this->upload->data();
  23. $file_name = $upload_data['file_name'];
  24. $this->image_resize($upload_data['full_path'], $file_name);
  25.  
  26. $data = array(
  27. 'success' => 1
  28. );
  29. }
  30.  
  31. $img = array(
  32. 'profilepic' => $file_name
  33. );
  34. $fname = $this->input->post('txtfname');
  35. $mname = $this->input->post('txtmname');
  36. $lname = $this->input->post('txtlname');
  37. $email = $this->input->post('txtemail');
  38. $user = $this->input->post('txtuser');
  39. $pass = $this->input->post('txtpass');
  40. $position = $this->input->post('txtposition');
  41. $schoolID = $this->input->post('txtschoolID');
  42.  
  43. $this->model->addNewUser($fname, $mname, $lname, $email, $user, $pass, $position, $schoolID, $img);
  44.  
  45.  
  46. generate_json($data);
  47.  
  48. }
  49.  
  50. public function image_resize($path, $file){
  51. $config_resize = array();
  52. $config_resize['image_library'] = 'gd2';
  53. $config_resize['source_image'] = $path;
  54.  
  55. $config_resize['maintain_ratio'] = TRUE;
  56. $config_resize['width'] = 75;
  57. $config_resize['height'] = 50;
  58. $config_resize['new_image'] = '../assets/uploads'.$file;
  59. $this->load->library('image_lib',$config_resize);
  60. $this->image_lib->resize();
  61.  
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement