maurobpp Posted April 11, 2014 Share Posted April 11, 2014 Hello, hope having some help, cant find no place to solve my problem, i have a script that basically what it doest is submit candidates CV forms. When a user fill the form whit his personal information and attached his CV, the form will save the information and the cv path in database and leave the cv in a folder inside of server, than will send a email to the company that post this job. Everything works fine, but only one problem, and this is the CV, this isnt attaching the CV in the email that is sent to the company. Could someone take a look to the code? if(isset($_FILES['files'])){ $errors= array(); foreach($_FILES['files']['tmp_name'] as $key => $tmp_name ){ $file_name = $key.$_FILES['files']['name'][$key]; $file_size =$_FILES['files']['size'][$key]; $file_tmp =$_FILES['files']['tmp_name'][$key]; $file_type=$_FILES['files']['type'][$key]; $random_digit=rand(0000,9999); $new_file_name=$random_digit.$file_name; if($file_size > 2097152){ $errors[]='File size must be less than 2 MB'; } $query2="INSERT into candidates (`firstname`,`lastname`,`mobile`,`email`,`message`,`id_company`,`titulo_anuncio`,`job_type`,`data`,ativo) VALUES('$firstname','$lastname','$mobile','$email_candidate','$message','$id_company','$title_en','$job_type','$data','1'); "; mysql_query($query2); $user_id = mysql_insert_id(); $query="INSERT into media (`id_candidate`,`file`,`size`,`type`) VALUES('$user_id','$new_file_name','$file_size','$file_type'); "; $to = $email; $subject = "Domainname.com | Portal of Jobs - New Candidate"; $body = ""; $body .= "Title Job: "; $body .= $title_en; $body .= "\n"; $body .= "Tel: "; $body .= $mobile; $body .= "\n"; $body .= "Email: "; $body .= $email_candidate; $body .= "\n"; $body .= "Message: "; $body .= $message; $body .= "\n"; $body .= "CV: "; $body .= "In Attachement"; $body .= "\n"; $headers = "From:" . $to; if (mail($to, $subject, $body,$headers)) $desired_dir="candidates_cv"; if(empty($errors)==true){ if(is_dir($desired_dir)==false){ mkdir("$desired_dir", 0700); // Create directory if it does not exist } if(is_dir("$desired_dir/".$new_file_name)==false){ move_uploaded_file($file_tmp,"$desired_dir/".$new_file_name); }else{ // rename the file if another one exist $new_dir="$desired_dir/".$new_file_name.time(); rename($file_tmp,$new_dir) ; } mysql_query($query); }else{ print_r($errors); } } if(empty($error)){ echo "<span style=\"color:green;font-weight:bold;\">Submitted whit Sucess Thanks</span>"; } } Regards Quote Link to comment Share on other sites More sharing options...
Skewled Posted April 12, 2014 Share Posted April 12, 2014 (edited) I think your missing some header information for sending a file in the email. $header = ''; $headers .= "From:" . $to; $headers .= "MIME-Version: 1.0\n"; $headers .= "Content-Type: multipart/mixed; boundary=\"\"\n\n"; $headers .= "This is a multi-part message in MIME format.\n"; $headers .= "Content-type: text/html; charset=utf-8\n"; $headers .= "Content-Transfer-Encoding: 7bit\n\n"; Edited April 12, 2014 by Skewled Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.