Advertisement
Guest User

Untitled

a guest
Sep 20th, 2015
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.78 KB | None | 0 0
  1. <?php
  2. class Upload extends CI_Controller {
  3.  
  4. public function __construct() {
  5.  
  6. parent::__construct();
  7. // Load the helpers
  8. $this->load->helper(array('form', 'url'));
  9. //$this->file_path = realpath(APPPATH . '../upload/large');
  10. //$this->file_path_url = realpath(APPPATH.'../upload/thumbs/');
  11. //load moadel ********
  12. $this->load->model('Camping_model');
  13.  
  14.  
  15. }
  16.  
  17. public function index() {
  18.  
  19. // Load the form
  20. $this->load->view('header');
  21. $this->load->view('camping_registration_continue', array('error' => ' ' ));
  22. $this->load->view('footer');
  23.  
  24. }
  25.  
  26. /**
  27. * Multiple upload functionality will fallback to CodeIgniters default do_upload()
  28. * method so configuration is backwards compatible between do_upload() and the new do_multi_upload()
  29. * method provided by Multi File Upload extension.
  30. *
  31. */
  32. public function do_upload(){
  33.  
  34. // Detect form submission.
  35. if($this->input->post('submit')){
  36.  
  37.  
  38.  
  39. $path = './upload/large/';
  40. $this->load->library('upload');
  41.  
  42. /**
  43. * Refer to https://ellislab.com/codeigniter/user-guide/libraries/file_uploading.html
  44. * for full argument documentation.
  45. *
  46. */
  47.  
  48. // Define file rules
  49. $this->upload->initialize(array(
  50. "upload_path" => $path,
  51. "allowed_types" => "gif|jpg|png",
  52. "max_size" => '2048',
  53. "encrypt_name" => TRUE,
  54. ));
  55.  
  56.  
  57. if($this->upload->do_multi_upload("uploadfile")){
  58.  
  59. //case success
  60. $data['upload_data'] = $this->upload->get_multi_upload_data();
  61.  
  62. $this->session->set_userdata($data);
  63. //let's call model function for inserting images into database
  64. echo "chika pika";
  65. var_dump($data);
  66. //$img['images'] = $this->Camping_model->insert_images($data);
  67. //var_dump($img);
  68. echo '<strong>'.'<p class = "bg-success">' . count($data['upload_data']) . 'File(s) successfully uploaded.</p>.'.'</strong>';
  69.  
  70.  
  71. } else {
  72. // Output the errors
  73. $errors = array('error' => $this->upload->display_errors('<p class = "bg-danger">', '</p>'));
  74. foreach($errors as $k => $error){
  75. echo $error;
  76. }
  77.  
  78. }
  79.  
  80. } else {
  81. echo '<strong>'.'<p class = "bg-danger">An error occured, please try again later.</p>.'.'</strong>';
  82.  
  83. }
  84. // Exit to avoid further execution
  85. exit();
  86. }
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement