Guest User

Untitled

a guest
May 19th, 2018
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  2.  
  3. class Capture extends CI_Controller {
  4.  
  5. public function __construct()
  6. {
  7. parent::__construct();
  8. $this->load->helper('url');
  9. }
  10.  
  11. public function index()
  12. {
  13. $this->load->view('capture');
  14. }
  15.  
  16. public function save()
  17. {
  18. $username = $this->input->post('username', true);
  19. $email = $this->input->post('email', true);
  20. $password = $this->input->post('password', true);
  21. $image = $this->input->post('image');
  22. $image = str_replace('data:image/jpeg;base64,','', $image);
  23. $image = base64_decode($image);
  24. $filename = 'image_'.time().'.png';
  25. file_put_contents(FCPATH.'/uploads/'.$filename,$image);
  26. $data = array(
  27. 'username' => $username,
  28. 'email' => $email,
  29. 'password' => password_hash($password, PASSWORD_DEFAULT),
  30. 'image' => $filename,
  31. );
  32.  
  33. $this->load->model('user');
  34. $res = $this->user->insert($data);
  35. echo json_encode($res);
  36. }
  37.  
  38. }
  39.  
  40. /* End of file Capture.php */
  41. /* Location: ./application/controllers/Capture.php */
Add Comment
Please, Sign In to add comment