Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 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. //form_upload('userfile');
  10. }
  11.  
  12. function index()
  13. {
  14. $this->load->view('upload_form', array('error' => ' ' ));
  15. }
  16.  
  17. function do_upload()
  18. {
  19. $config['upload_path'] = '/uploads/';
  20. $config['allowed_types'] = 'gif|jpg|png';
  21. $config['max_size'] = '100';
  22. $config['max_width'] = '1024';
  23. $config['max_height'] = '768';
  24.  
  25. $this->load->library('upload', $config);
  26.  
  27. if ( ! $this->upload->do_upload())
  28. {
  29. $error = array('error' => $this->upload->display_errors());
  30.  
  31. $this->load->view('upload_form', $error);
  32. }
  33. else
  34. {
  35. $data = array('upload_data' => $this->upload->data());
  36.  
  37. $this->load->view('upload_success', $data);
  38. }
  39. }
  40. }
  41. ?>
  42.  
  43. <html>
  44. <head>
  45. <title>Upload Form</title>
  46. </head>
  47. <body>
  48.  
  49. <?php echo $error;?>
  50.  
  51. <?php echo form_open_multipart('upload/do_upload');?>
  52.  
  53. <input type="file" name="userfile" size="20" />
  54.  
  55. <br /><br />
  56.  
  57. <input type="submit" value="upload" />
  58.  
  59. </form>
  60.  
  61. </body>
  62. </html>
  63.  
  64. <?php echo form_open_multipart('/upload/do_upload');?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement