jamsir

Untitled

Sep 25th, 2013
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. <?php
  2.  
  3. class Upload extends CI_Controller {
  4.  
  5. function __construct()
  6. {
  7. parent::__construct();
  8. $this->load->helper(array('form', 'url'));
  9.  
  10.  
  11.  
  12. }
  13.  
  14. function index()
  15. {
  16. $this->load->view('upload_form', array('error' => ' ' ));
  17. }
  18.  
  19.  
  20. public function do_upload()
  21. {
  22. $config['upload_path'] = './uploads/';
  23. $config['allowed_types'] = 'gif|jpg|png';
  24. $config['max_size'] = '100';
  25. $config['max_width'] = '1024';
  26. $config['max_height'] = '768';
  27.  
  28.  
  29. $this->load->library('upload', $config);
  30.  
  31. if ($this->upload->do_upload('userfile') == TRUE)
  32. {
  33. $data = $this->upload->data();
  34. $nama_file = $data['file_name'];
  35. $array = array('title' => 'Title', 'gambar' => $nama_file);
  36. $this->db->insert('tes', $array);
  37. }
  38. else
  39. {
  40. $error = array('error' => $this->upload->display_errors());
  41.  
  42. $this->load->view('upload_form', $error);
  43. }
  44. }
  45.  
  46.  
  47.  
  48.  
  49. }
  50. ?>
Advertisement
Add Comment
Please, Sign In to add comment