I have this code which actually is not working completely, I get the email with all the info, but the email does not include the file that I'm trying to attach... (the only way I get it is deleting the jquery ajax function) Any idea why? (I did this because I want to get an alert in the same page after submit the form) Thanks for your help!
HTML
<form class="ajax_nueva_idea" action="php/send_idea.php" method="post" enctype="multipart/form-data">
  <div>
    <input required="" id="nombreproyecto" name="nombreproyecto" type="text" class="validate">
  </div>
  <div>
    <input required="" id="sector_for" name="sector_for" type="text" class="validate">
  </div>
  <div>
    <input required="" id="ubigeo_for" type="text" name="ubigeo_for" class="validate">
  </div>
  <div>
    <input required="" id="videoex_for" name="videoex_for" type="text" class="validate">
  </div>
  <div>
   <select required="" id="etapa_for" name="etapa_for">
    <option value="0"</option>
    <option value="1">1/4</option>
    <option value="2">2/4</option>
    <option value="3">3/4</option>
    <option value="4">4/4</option>
  </select>
  </div>
  <div>
    <input name="attachment" type="file">
  </div>
  <div>
    <textarea required="" id="info_for" name="info_for"></textarea>
  </div>
  <div>
    <button type="submit" name="action" id="enviar_proyecto">Guardar
    </button>
  </div>
</form>
PHP
<?php
    $to = 'example@msn.com';
    $nombreproyecto = $_POST['nombreproyecto']; 
    $sector = $_POST['sector_for'];
    $ciudad = $_POST['ubigeo_for'];
    $video = $_POST['videoex_for'];
    $etapa = $_POST['etapa_for'];
    $subject = "'gobig.com.co' Nuevo proyecto "."'".$nombreproyecto."'"; 
    $message = 
    "Cargo: ".$nombreproyecto."\n".
    "Sector o industria: ". $sector ."\n". 
    "Ciudad: ".$ciudad ."\n".
    "Link video:". $video ."\n". 
    "Etapa del proyecto:".$etapa."\n" . 
    "Frase convencer: ".$_POST['info_for'];
    $tmpName = $_FILES['attachment']['tmp_name']; 
    $fileType = $_FILES['attachment']['type']; 
    $fileName = $_FILES['attachment']['name']; 
    $headers = "From: $nombreproyecto"; 
    if (file($tmpName)) { 
      $file = fopen($tmpName,'rb'); 
      $data = fread($file,filesize($tmpName)); 
      fclose($file); 
      $randomVal = md5(time()); 
      $mimeBoundary = "==Multipart_Boundary_x{$randomVal}x"; 
      $headers .= "\nMIME-Version: 1.0\n"; 
      $headers .= "Content-Type: multipart/mixed;\n" ;
      $headers .= " boundary=\"{$mimeBoundary}\""; 
      $message = "This is a multi-part message in MIME format.\n\n" . 
      "--{$mimeBoundary}\n" . 
      "Content-Type: text/plain; charset=\"iso-8859-1\"\n" . 
      "Content-Transfer-Encoding: 7bit\n\n" . 
      $message . "\n\n"; 
      $data = chunk_split(base64_encode($data)); 
      $message .= "--{$mimeBoundary}\n" . 
      "Content-Type: {$fileType};\n" . 
      " name=\"{$fileName}\"\n" . 
      "Content-Transfer-Encoding: base64\n\n" . 
      $data . "\n\n" . 
      "--{$mimeBoundary}--\n"; 
    } 
    $flgchk = mail ("$to", "$subject", "$message", "$headers"); 
    if($flgchk){
      //echo "A email has been sent to: $to";
     }
    else{
      //echo "Error in Email sending";
    }
?>
JAVASCRIPT
jQuery('.ajax_nueva_idea').submit( function() {
    $.ajax({
        url     : $(this).attr('action'),
        type    : $(this).attr('method'),
        data    : $(this).serialize(),
        success : function( data ) {
                    alert('Idea guardada exitosamente!');
                    $('#enviar_proyecto').html('Guardado <i class="material-icons right">check</i>');
                  },
        error   : function(){
                     alert('Something wrong');
                  }
    });
    return false;
});