Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Upload extends CI_Controller {
- function __construct()
- {
- parent::__construct();
- $this->load->helper(array('form', 'url'));
- }
- function index()
- {
- $this->load->view('upload_form', array('error' => ' ' ));
- }
- public function do_upload()
- {
- $this->load->database();
- $config['upload_path'] = './uploads/';
- $config['allowed_types'] = 'gif|jpg|png';
- $config['max_size'] = '100';
- $config['max_width'] = '1024';
- $config['max_height'] = '768';
- $this->load->library('upload', $config);
- if ($this->upload->do_upload('userfile') == TRUE)
- {
- $data = $this->upload->data();
- $nama_file = $data['file_name'];
- $array = array('title' => 'Title', 'gambar' => $nama_file);
- $this->db->insert('tes', $array);
- }
- else
- {
- $error = array('error' => $this->upload->display_errors());
- $this->load->view('upload_form', $error);
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement