Advertisement
Guest User

Untitled

a guest
Aug 27th, 2014
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  2.  
  3. class Admin extends CI_Controller {
  4.  
  5.  
  6. public function __construct()
  7.  
  8. {
  9. parent::__construct();
  10.  
  11. $this->load->helper('url');
  12. $this->load->Model('Mod_admin');
  13.  
  14. }
  15.  
  16. public function index()
  17. {
  18. $this->load->helper(array('form')); //login purposes
  19. $this->load->view('template/header');
  20. $data['branches'] = $this->Mod_admin->getAllBranches();
  21. $this->load->view('index',$data);
  22.  
  23. }
  24.  
  25.  
  26. public function account()
  27. {
  28. $this->load->view('account', array('error' => ' ' ));
  29. }
  30.  
  31. public function do_upload()
  32. {
  33. $config['upload_path'] = './uploads/';
  34. $config['allowed_types'] = 'gif|jpg|png';
  35.  
  36.  
  37. $this->load->library('upload', $config);
  38.  
  39. if ( ! $this->upload->do_upload())
  40. {
  41. $error = array('error'=>$this->upload->display_errors());
  42. $this->load->view('account', $error);
  43. }
  44. else
  45. {
  46. $data=array('upload_data'=>$this->upload->data());
  47. $this->load->view('success', $data);
  48. }
  49. }
  50.  
  51.  
  52. }//last curly
  53.  
  54. <html>
  55. <body>
  56. <?php echo form_open_multipart('http://localhost/do_upload');?>
  57.  
  58. <input type="file" name="userfile" />
  59.  
  60. <br /><br />
  61.  
  62. <input type="submit" value="upload" />
  63.  
  64. </form>
  65. </body>
  66. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement