Welcome Guest, Not a member yet? Register   Sign In
Uploading Multiple Files As Email Attachment
#5

[eluser]TheFuzzy0ne[/eluser]
Indeed, I can.

Code:
$config['upload_path'] = '/usr/local/var/www/Test/ci/uploads/';
$config['allowed_types'] = 'txt|pdf';
$config['overwrite'] = TRUE;
$config['encrypt_name'] = TRUE;

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

foreach ($_FILES as $key => $value) { // Loop through each file in the $_FILES array.
    if (!empty($key['userfile'])) {
        $this->upload->initialize($config); // Set up the upload library configuration (probably best done BEFORE the loop).
        
        if (!$this->upload->do_upload($key)) { // Show a view if the upload of a SINGLE file fails. Is this a partial, or a full page?
            $data['main_content'] = 'emailsystem/emails_view';
            $data['error'] = $this->upload->display_errors('<p class="error">', '</p>');
            $this->load->view('includes/no_js/template', $data);
        } else { // We made it thus far, all is good. Yippee!
            $return = $this->upload->data();

            // Blah, blah, blah
            
            $this->email->attach($file); Attach the CURRENT FILE ONLY

            if (!$this->email->send()) { // If sending the mail fails, load a view. Is this a partial, or an entire page? I don't know...
                $this->emailview();
            } else {
                $this->session->set_flashdata('emailview', 'Email Sent To ' . $email . '. With A Number ' . $anum . '');
                redirect('email_controller/emailview', 'location'); // Redirect after sending a single file. Are we still in the loop? I think so!
                // This should be OUTSIDE of the loop.
            }
        }
    }
}


Messages In This Thread
Uploading Multiple Files As Email Attachment - by El Forum - 03-28-2013, 07:39 AM
Uploading Multiple Files As Email Attachment - by El Forum - 03-28-2013, 08:08 AM
Uploading Multiple Files As Email Attachment - by El Forum - 03-28-2013, 08:24 AM
Uploading Multiple Files As Email Attachment - by El Forum - 03-28-2013, 08:33 AM
Uploading Multiple Files As Email Attachment - by El Forum - 03-28-2013, 08:34 AM
Uploading Multiple Files As Email Attachment - by El Forum - 03-28-2013, 08:38 AM
Uploading Multiple Files As Email Attachment - by El Forum - 03-28-2013, 08:48 AM
Uploading Multiple Files As Email Attachment - by El Forum - 03-28-2013, 08:55 AM
Uploading Multiple Files As Email Attachment - by El Forum - 03-28-2013, 12:48 PM
Uploading Multiple Files As Email Attachment - by El Forum - 03-28-2013, 07:20 PM
Uploading Multiple Files As Email Attachment - by El Forum - 03-29-2013, 01:23 AM
Uploading Multiple Files As Email Attachment - by El Forum - 03-29-2013, 01:26 AM
Uploading Multiple Files As Email Attachment - by El Forum - 03-29-2013, 05:41 AM
Uploading Multiple Files As Email Attachment - by El Forum - 03-29-2013, 05:42 AM
Uploading Multiple Files As Email Attachment - by El Forum - 03-29-2013, 05:45 AM
Uploading Multiple Files As Email Attachment - by El Forum - 03-29-2013, 06:57 AM
Uploading Multiple Files As Email Attachment - by El Forum - 03-29-2013, 07:01 AM
Uploading Multiple Files As Email Attachment - by El Forum - 03-29-2013, 07:16 AM
Uploading Multiple Files As Email Attachment - by El Forum - 03-29-2013, 07:23 AM
Uploading Multiple Files As Email Attachment - by El Forum - 03-29-2013, 07:34 AM
Uploading Multiple Files As Email Attachment - by El Forum - 03-29-2013, 07:50 AM
Uploading Multiple Files As Email Attachment - by El Forum - 03-29-2013, 08:03 AM
Uploading Multiple Files As Email Attachment - by El Forum - 03-29-2013, 08:15 AM
Uploading Multiple Files As Email Attachment - by El Forum - 03-29-2013, 09:02 AM



Theme © iAndrew 2016 - Forum software by © MyBB