PHP フォームから自分のメール ID に 2 つの履歴書を取得しようとしています。すべての情報を完全に取得していますが、添付ファイルが空白になっています。理由はわかりませんでした。
どんな助けでも大歓迎です。HTML コードと PHP コードの両方を以下に示します。前もって感謝します。
<------------------------HTMLコード----------------------- ------------------>
<form name="Form5" method="post" action="js/curent-job.php" onsubmit="return ValidateForm2()">
<table width="55%" align="left" cellpadding="0" cellspacing="0">
<tr>
<td colspan="3" style="height:70px;">
<p>Please submit your updated resume with the below details. </p>
</td>
</tr>
<tr>
<td width="93"><label for="Full_Name" class="required">Name:</label></td>
<td width="40"> </td>
<td width="252"><input name="Full_Name" id="Full_Name" maxlength="80" style="width: 250px; height:20px" type="text"></td>
</tr>
<tr style="height:5px">
<td colspan="3"></td>
</tr>
<tr>
<td><label for="Tel_No" class="required">Telephone:</label></td>
<td> </td>
<td><input name="Tel_No" id="Tel_No" maxlength="100" style="width: 250px; height:20px" type="text"></td>
</tr>
<tr style="height:5px">
<td colspan="3"></td>
</tr>
<tr>
<td> <label for="Email_Address" class="required">Email Id:</label></td>
<td> </td>
<td> <input name="Email_Address" id="Email_Address" maxlength="100" style="width: 250px; height:20px" type="text"></td>
</tr>
<tr style="height:5px">
<td colspan="3"></td>
</tr>
<tr>
<td> <label for="Resume" class="required">Resume 1:</label></td>
<td> </td>
<td> <input name="Resume" id="Resume" maxlength="100" type="file"></td>
</tr>
<tr>
<td> <label for="Resume2" class="required">Resume 2 :</label></td>
<td> </td>
<td> <input name="Resume2" id="Resume2" maxlength="100" type="file"></td>
</tr>
<tr style="height:5px">
<td colspan="3"></td>
</tr>
<tr>
<td><label for="Description" class="required">Description:</label></td>
<td> </td>
<td><textarea style="width: 250px; height: 60px;" name="Description" id="Description" maxlength="3000"></textarea></td>
</tr>
<tr style="height:5px">
<td colspan="3"></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><input type="image" src="images/button.png" width="75" height="30" /></td>
</tr>
</table>
</form>
<------------------------PHP CODE---------------------------------------->
<?php
if(isset($_POST['Email_Address'])) {
$files = array("Resume.docx", "Resume2.docx");
$email_to = "abc@mydomain.com";
$email_subject = "My Company - Career Enquiry";
$thankyou = "http://www.mydomain.com/thanks.html";
$email_sender = "admin@mydomain.com";
// boundary
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
function died($error) {
echo "Sorry, but there were error(s) found with the form you submitted. ";
echo "These errors appear below.<br /><br />";
echo $error."<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}
$full_name = $_POST['Full_Name']; // required
$email_from = $_POST['Email_Address']; // required
$telephone = $_POST['Tel_No']; //required
$comments = $_POST['Description']; // required
$email_message = "Message details below.\r\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "Full Name: ".clean_string($full_name)."\r\n";
$email_message .= "Email: ".clean_string($email_from)."\r\n";
$email_message .= "Contact Number: ".clean_string($telephone)."\r\n";
$email_message .= "Message: ".clean_string($comments)."\r\n";
// multipart boundary
$email_message .= "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/plain; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $email_message . "\n\n";
$email_message .= "--{$mime_boundary}\n";
// preparing attachments
for($x=0;$x<count($files);$x++){
$file = fopen($files[$x],"rb");
$data = fread($file,filesize($files[$x]));
fclose($file);
$data = chunk_split(base64_encode($data));
$email_message .= "Content-Type: {\"application/octet-stream\"};\n" . " name=\"$files[$x]\"\n" .
"Content-Disposition: attachment;\n" . " filename=\"$files[$x]\"\n" .
"Content-Transfer-Encoding: base64\n\n" . $data . "\n\n";
$email_message .= "--{$mime_boundary}\n";
}
$headers = 'From: '.$email_sender."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
// headers for attachment
$headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\"";
@mail($email_to, $email_subject, $email_message, $headers);
header("Location: $thankyou");
?>
<script>location.replace('<?php echo $thankyou;?>')</script>
<?php
}
die();
?>