当用户填写表格并填写他的个人信息并附上他的简历时,表格会将信息和cv路径保存在数据库中并将cv保留在服务器内的文件夹中,而不是向公司发送电子邮件发布这份工作。一切正常,但只有一个问题,这就是简历,这不是将CV附加到发送给公司的电子邮件中。
有人可以查看代码吗?
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>";
}
}