Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Upload extends CI_Controller {
- public function __construct() {
- parent::__construct();
- // Load the helpers
- $this->load->helper(array('form', 'url'));
- //$this->file_path = realpath(APPPATH . '../upload/large');
- //$this->file_path_url = realpath(APPPATH.'../upload/thumbs/');
- //load moadel ********
- $this->load->model('Camping_model');
- }
- public function index() {
- // Load the form
- $this->load->view('header');
- $this->load->view('camping_registration_continue', array('error' => ' ' ));
- $this->load->view('footer');
- }
- /**
- * Multiple upload functionality will fallback to CodeIgniters default do_upload()
- * method so configuration is backwards compatible between do_upload() and the new do_multi_upload()
- * method provided by Multi File Upload extension.
- *
- */
- public function do_upload(){
- // Detect form submission.
- if($this->input->post('submit')){
- $path = './upload/large/';
- $this->load->library('upload');
- /**
- * Refer to https://ellislab.com/codeigniter/user-guide/libraries/file_uploading.html
- * for full argument documentation.
- *
- */
- // Define file rules
- $this->upload->initialize(array(
- "upload_path" => $path,
- "allowed_types" => "gif|jpg|png",
- "max_size" => '2048',
- "encrypt_name" => TRUE,
- ));
- if($this->upload->do_multi_upload("uploadfile")){
- //case success
- $data['upload_data'] = $this->upload->get_multi_upload_data();
- $this->session->set_userdata($data);
- //let's call model function for inserting images into database
- echo "chika pika";
- var_dump($data);
- //$img['images'] = $this->Camping_model->insert_images($data);
- //var_dump($img);
- echo '<strong>'.'<p class = "bg-success">' . count($data['upload_data']) . 'File(s) successfully uploaded.</p>.'.'</strong>';
- } else {
- // Output the errors
- $errors = array('error' => $this->upload->display_errors('<p class = "bg-danger">', '</p>'));
- foreach($errors as $k => $error){
- echo $error;
- }
- }
- } else {
- echo '<strong>'.'<p class = "bg-danger">An error occured, please try again later.</p>.'.'</strong>';
- }
- // Exit to avoid further execution
- exit();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement