Advertisement
Bagosep

Controller CI

Sep 8th, 2017
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.38 KB | None | 0 0
  1. <?php
  2. defined('BASEPATH') OR exit('No direct script access allowed');
  3.  
  4. class Main extends CI_Controller {
  5.  
  6.         public function __construct()
  7.         {      
  8.                 parent::__construct();
  9.                 $this->load->model("Mymodel");
  10.        
  11.         }
  12.  
  13.  
  14.     public function index()
  15.     {
  16.        
  17.                 $data = $this->Mymodel->GetSiswa('siswa');
  18.                 $this->load->view("main/index", array('siswa' => $data));
  19.     }
  20.  
  21.     public function insert()
  22.     {
  23.         $this->load->view("main/add_siswa");
  24.     }
  25.  
  26.     public function tambah()
  27.         {
  28.                 $config['upload_path']          = './uploads/';
  29.                 $config['allowed_types']        = 'gif|jpg|png';
  30.                 $config['max_size']             = 100;
  31.                 $config['max_width']            = 1024;
  32.                 $config['max_height']           = 768;
  33.  
  34.                 $this->load->library('upload', $config);
  35.  
  36.                 if ( ! $this->upload->do_upload('userfile'))
  37.                 {
  38.                         $error = array('error' => $this->upload->display_errors());
  39.  
  40.                         $this->load->view('upload_form', $error);
  41.                 }
  42.                 else
  43.                 {
  44.                         $data = array('upload_data' => $this->upload->data());
  45.  
  46.                         $this->load->view('upload_success', $data);
  47.                 }
  48.         }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement