Advertisement
tanyaaja

controller/regis.php

May 17th, 2018
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. <?php
  2. defined('BASEPATH') OR exit('No direct script access allowed');
  3.  
  4. /**
  5. *
  6. */
  7. class Regis extends CI_Controller
  8. {
  9. public function __construct()
  10. {
  11. parent::__construct();
  12. $this->load->model('RegisModel');
  13. $this->load->library('upload');
  14.  
  15. }
  16. public function index(){
  17. $this->load->view('home_view');
  18. }
  19.  
  20. public function insertdata(){
  21.  
  22. // proses upload gambar
  23. $config['upload_path'] = 'photo'; // folder upload
  24. $config['allowed_types'] = 'gif|jpg|jpeg|png'; // jenis file
  25. $config['max_size'] = '3000'; // besar file 3MB
  26. $config['max_width'] = '4480';
  27. $config['max_height'] = '4480';
  28.  
  29. $this->load->library('upload', $config);
  30. if (! $this->upload->do_upload('foto')) // sesuaikan namanya dengan formnnya
  31. {
  32. $error = array('error' => $this->upload->display_errors());
  33. echo "gagal upload";
  34. }
  35. $file = $this->upload->data();
  36. $foto = $file['file_name'];
  37.  
  38. // proses registrasi
  39. $data_member = array(
  40. 'nama' =>$this->input->post('nama'),
  41. 'email' =>$this->input->post('email'),
  42. 'tlpn' =>$this->input->post('tlpn'),
  43. 'foto' =>$foto
  44. );
  45. $this->RegisModel->simpan($data_member);
  46. }
  47.  
  48. }
  49. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement