title: codeigniter email with attachment
body: <p>my problem is: Sending email with attachtment in Codeigniter 3.1.5
  I want to send a form with name, email, phone and pdf file upload by user as attachment to email but I get problem. please help me</p>
  
  <p>form:</p>
  
  
  
  <pre><code>    &lt;div&gt;
          &lt;label for="name" class="label"&gt;Name:&lt;/label&gt;
          &lt;input type="text" name="name"&gt;
      &lt;/div&gt;
  
      &lt;div&gt;
          &lt;label for="email" class="label"&gt;Email:&lt;/label&gt;
          &lt;input type="email" name="email"&gt;
      &lt;/div&gt;
  
          &lt;div&gt;
              &lt;label for="email" class="label"&gt;Phone:&lt;/label&gt;
              &lt;input type="text" name="phone"&gt;
          &lt;/div&gt;
  
          &lt;hr&gt;
      &lt;div&gt;
          &lt;label for="file"&gt;File: &lt;/label&gt;
          &lt;input type="file" name="file"&gt;
      &lt;/div&gt;
  
          &lt;hr&gt;
      &lt;button type="submit" name="submit" class="button is-danger" &gt;Send Form&lt;/button&gt;
      &lt;/div&gt;
  
      &lt;?php echo form_close(); ?&gt;
  </code></pre>
  
  <p>And this is controller that the form return</p>
  
  <p>Controller:</p>
  
  <p>public function send(){</p>
  
  <pre><code>    $config = [
          'porotocol' =&gt; 'sendmail',
          'smtp_host' =&gt; 'data',
          'smtp_port' =&gt; 993,
          'smtp_user' =&gt; 'email',
          'smtp_pass' =&gt; 'password',
          'mailtype' =&gt; 'html',
          'charset' =&gt; 'utf-8',
          'wordwrap' =&gt; TRUE,
      ];
  
          $this-&gt;load-&gt;library('email', $config);
          $this-&gt;email-&gt;set_newline("\r\n");
  
      $data = [
          'name' =&gt; $this-&gt;input-&gt;post('name'),
          'email' =&gt; $this-&gt;input-&gt;post('email'),
          'phone' =&gt; $this-&gt;input-&gt;post('phone'),
      ];
  
          $this-&gt;email-&gt;from($data['email'], $data['name']);
          $this-&gt;email-&gt;to('test@test.com');
          $this-&gt;email-&gt;subject('form');
  
      $file_name= $this-&gt;input-&gt;post('file');
      $this-&gt;email-&gt;attach($file_name);
  
          $message = $this-&gt;load-&gt;view('forms/formformat', $data, TRUE);
          $this-&gt;email-&gt;message($message);
  
      if($this-&gt;email-&gt;send()){
          $this-&gt;session-&gt;set_flashdata("email_sent","ok");
          redirect('forms/mailform');
      } else {
          $this-&gt;session-&gt;set_flashdata("email_nosent","error");
          $data['content'] = 'forms/mailform';
          $this-&gt;load-&gt;view('master', $data);
      }
  
  }
  </code></pre>
  
  <p>Also I have tried with upload library but the problem didn't solved. 
  would you please help me how I can send the form with attachment to email.
  thank you</p>