Jump to content

maurobpp

New Members
  • Posts

    1
  • Joined

  • Last visited

maurobpp's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. 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
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.