I have a contact form (contact form = cart) where users can upload a file attachment and everything works, except no attachment is sent to the mail.. I get *"You did not select a file to upload."* 

My view:

```html
<?php 
$order_cart_form_attr = array('class' => 'ui equal width form', 'id' => 'order_cart_form', 'enctype' => 'multipart/form-data');
echo form_open_multipart('Kassa/send_cart', $order_cart_form_attr);
?>

<div class="fields">
<div class="field ui left icon input">
      <input type="text" class="required-group" name="order_firstname" id="order_firstname" placeholder="Имя">
      <i class="user icon"></i>
</div>

<div class="field ui left icon input">
      <input type="text" name="order_lastname" id="order_lastname" placeholder="Фамилия">
      <i class="user icon"></i>
</div>
</div>

<div class="fields">
<div class="field ui left icon input">
      <input type="text" class="required-group" name="order_email" id="order_email"  placeholder="Email">
      <i class="mail icon"></i>
</div>

<div class="field ui left icon input">
      <input type="text" class="required-group" name="order_phone" id="order_phone" placeholder="Телефон">
      <i class="phone icon"></i>
</div>
</div>

<br><br>
<div class="fields">

<div class="field ui left icon input">
      <input type="text" class="required-group" name="order_inn" id="order_inn"  placeholder="ИНН">
      <i class="suitcase icon"></i>
</div>

<div class="field ui left icon input">
      <input type="file" name="order_file" id="order_file" />
      <i class="cloud upload icon"></i>
</div>

</div>
<br><br>

 <div class="field">
    <textarea class="required-group" name="order_comment" id="order_comment" placeholder="Комментарий к заказу"></textarea>
</div>

<button id="order_cart_submit_btn" class="ui fluid vertical animated button" tabindex="0">
<div class="hidden content"> <i class="shop icon"></i> </div>
<div class="visible content">
    Послать заявку
</div>
</button>

<div id="contactFormResponseMSG"></div>

<?php echo form_close(); ?>
```

Controller:

```html
public function send_cart() {

$config['protocol'] = 'sendmail';
$config['mailpath'] = '/usr/sbin/sendmail';
$config['charset'] = 'UTF-8';
$config['wordwrap'] = TRUE;
$config['mailtype'] = 'html'; 
$this->email->initialize($config);

$this->form_validation->set_error_delimiters('<div class="error">', '</div>');

$order_firstname = $this->input->post('order_firstname', TRUE);
$order_lastname = $this->input->post('order_lastname', TRUE);
$order_email = $this->input->post('order_email', TRUE);
$order_phone = $this->input->post('order_phone', TRUE);
$order_comment = $this->input->post('order_comment', TRUE);
$order_inn = $this->input->post('order_inn', TRUE);
$order_file = $this->input->post('order_file', TRUE);

$order_CartTotal = $this->cart->format_number($this->cart->total());

foreach ($this->cart->contents() as $items): 
 $order_CartInfo = $this->input->post('order_NameDiametr', TRUE);
 $order_NameDiametr = $items['name'].'  |  '.$items['options']['diametr']. "<br>";
endforeach;

$config['upload_path']          = './uploads/';
$config['allowed_types']        = '*';

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

if ( ! $this->upload->do_upload('order_file')) {
                   $error = array('error' => $this->upload->display_errors());
                   print_r($error);
                   print_r($this->upload->data());
}
else {
                       $this->upload->do_upload('order_file');
}

$this->form_validation->set_rules('order_firstname', 'Order_lastname', 'required|trim');
$this->form_validation->set_rules('order_lastname', 'Order_lastname', 'trim');
$this->form_validation->set_rules('order_email', 'Order_email', 'valid_email|trim');
$this->form_validation->set_rules('order_phone', 'Order_phone', 'required|trim');

if ($this->form_validation->run() == FALSE) {
    print "<div class='ui negative message'>";
 print  validation_errors();
    print "</div>";
}
else {

$this->email->set_newline("\r\n");   
$this->email->from('---', '---');
$this->email->to('---');

$this->email->subject('---');

$body = "Имя: ".$order_firstname . "<br>";
$body .= "Фамилия: ".$order_lastname . "<br>";
$body .= "Телефон: ".$order_phone . "<br>";
$body .= "ИНН: ".$order_inn . "<br>";
$body .= "File: ".$this->email->attach($order_file) . "<br>";
$body .= "Email: ".$order_email . "<br><br>";
$body .= "Комментарий к заказу: ".$order_comment. "<br><br>";

foreach ($this->cart->contents() as $items): 
 $body .= $items['name'].'  |  '.$items['options']['diametr']. "<br><br>";
endforeach;

$body .= "Итого: ".$order_CartTotal." руб";
$this->email->message($body);   

$this->email->attach($order_file);

$this->email->send();

}
```

Could it depend on something in the ajax call?

```js
$(document).on("click", "#order_cart_submit_btn", function (e) {

$("#order_cart_form").validate({

rules: {
        order_firstname: "required",
        order_lastname: {
         required: false
   },
         order_email: {
         required: false,
         email: true
   },
   order_phone: {
         required: true,
         digits: true
   },
   order_comment: {
         required: true
   }
},
messages: {
      order_firstname: {
         required: "Ваше имя"
         },
         order_lastname: {
         required: "Ваша фамилия"
         },
         order_phone: {
         required: "Ваш номер",
         digits: "Ваш номер"
     /* minlength: jQuery.validator.format("Minst 8 siffror."),
      maxlength: jQuery.validator.format("Max 15 siffror.")*/
         },
         order_email: {
         required: "Ваш email",
      email: "Ваш email"
         },
         order_comment: {
         //required: "Комментарий к заказу"
         required: ""
         },
   /*order_message: {
         required: "Vänligen skriv ett meddelande"
         },*/
},
         errorClass: 'error-view',
         validClass: 'success-view',
         errorElement: 'span',
         debug: true,

    submitHandler: function(form) {
       e.preventDefault();

     $.ajax({
        url: "Kassa/send_cart",
     type: "POST",
     data: $('#order_cart_form').serialize(),
      cache: false,

  beforeSend: function(data, xhr, status) {
     console.log(data);    
        },

  success: function(data, xhr, status) {
     if (data.status == 'fail') {
           console.log("FAIL ALERT");
$("#contactFormResponseMSG").html('<div class="ui negative message">Ваша заявка не была отправлена. <br> Попробуйте еще раз позже.</div>');
$('#contactUsForm').form('clear');
        }
   else {
$("#contactFormResponseMSG").html('<div id="order_cart_form_success_msg" class="ui positive message">Спасибо. <br> Ваша заявка была успешно отправлена. Мы свяжемся с Вами в ближайшее время.</div>');
$('#order_cart_form').form('clear');
}
}
});
return false;
form.submit();
}

});

});
```