These are chat archives for codeigniter-id/codeigniter-id.github.io

13th
Sep 2017
Netlinqs
@netlinqs
Sep 13 2017 14:51
Hi i would like attach multiple files an email. Someone can help me? Thanks.
This is my code:
                $config['upload_path']          = './media/images/uploads/';
                $config['allowed_types']        = 'gif|jpg|png|pdf';
                $config['max_size']             = 100;
                $config['max_width']            = 1024;
                $config['max_height']           = 768;

                $files = $_FILES;
                $count = count($_FILES['userfile']['name']);

                for($i = 0; $i < $count; $i++) {
                   $_FILES['userfile']['name']     = $files['userfile']['name'][$i];
                   $_FILES['userfile']['type']     = $files['userfile']['type'][$i];
                   $_FILES['userfile']['tmp_name'] = $files['userfile']['tmp_name'][$i];
                   $_FILES['userfile']['error']    = $files['userfile']['error'][$i];
                   $_FILES['userfile']['size']     = $files['userfile']['size'][$i]; 

                $this->load->library('upload', $config);

                if ( ! $this->upload->do_upload('userfile'))
                {
                      $this->form_validation->set_error_delimiters('<p class="error">', '</p>');
                      $error = array('error' => $this->upload->display_errors());

                }
                else
                {
                     $upload_data = $this->upload->data();
                }

//attach email
$this->email->attach($upload_data['full_path']);