• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
attaching files with email class

#1
[eluser]brian88[/eluser]
The email debugger tells me the email sends but cannot find the file path for the attached file.

Is it possible for users to attach a file directly from their computer? or do I have to upload the file on my host then attach it?

controller
Code:
function sendEmail() {
  $this->load->library('email');
  $this->email->from( $this->input->post('email'), $this->input->post('name'));
  $this->email->to('[email protected]');
  $this->email->subject('test');
  $this->email->message( $this->input->post('comments') );
  $this->email->attach($this->input->post('resume'));
  $this->email->send();
  //redirect('thanks');
  echo $this->email->print_debugger();
} // end function

view
Code:
<form action="<?php echo base_url('main/sendEmail'); ?>" method="post">
      <ul>
       <li>
        <label for="name">Full Name:</label>
        &lt;input type="text" id="name" name="name" /&gt;
       </li>
      
       <li>
        <label for="email">Email:</label>
        &lt;input type="email" id="email" name="email" /&gt;
       </li>
      
       <li>
        <label for="resume">Upload Resume:</label>
        &lt;input type="file" id="resume" name="resume" /&gt;
       </li>
      
       <li>
        <label for="comments">Comments:</label>
        &lt;textarea id="comments" name="comments" rows="5" cols="45"&gt;&lt;/textarea>
       </li>
      
       <li>
        &lt;input id="submit" type="submit" value="Submit" /&gt;
       </li>
      </ul>&lt;!-- ul End --&gt;
&lt;/form&gt;&lt;!-- Form End --&gt;

#2
[eluser]brian88[/eluser]
Has anyone had success attaching files with the email class?

#3
[eluser]CroNiX[/eluser]
Code:
$this->email->attach($this->input->post('resume'));

Files aren't accessible via $_POST.

You'll have to follow the process for saving an uploaded file, and then attaching that saved file by supplying the full saved file path (saved on your server), to the email::attach() method.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.