我一直在努力使用 php 获取带有附件的邮件。
下面是我的申请表.php
<form name="frm" action="ThankYou.php" method="post" style="padding-top:10px;">
<table style="text-align: left; width: 100%; color: rgb(255, 0, 0);
font-family: Arial; font-size: 11px; font-weight: bold;"
rules="all" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td>*mandatory fields</td>
</tr>
<tr>
<td align="left" valign="top"><p><table id="Table2" cellSpacing="0" cellPadding="3" width="100%" align="center"
border="0">
<tr>
<td style="WIDTH: 152px; HEIGHT: 31px" vAlign="top" align="left"><span id="Label1" class="text" class="text" style="background-color:Transparent;"><span style="font-size:13px; font-family:Arial; font-weight: normal;
color:#000000"><span id="Label15" class="asterix" style="color:Red;"></span>Form
of address</span></span></td>
<td style="HEIGHT: 31px"><select name="DDtitle" id="DDtitle" class="formtext">
<option value=" ">Select</option>
<option value="Mr.">Mr.</option>
<option value="Ms.">Ms.</option>
<option value="Ms.">Mrs.</option>
</select></td>
</tr><br>
<tr>
<td height="35" valign="top"><span style="font-size:13px; font-family:Arial; font-weight: normal;
color:#000000"><font color="#FF0000"><sup>*</sup></font>First Name:<font color="#FF0000"></font></span></td>
<td valign="top"><input type="text" size="35" name="name" id="name" value=""></td></tr>
<tr>
<td height="35" valign="top"><span style="font-size:13px; font-family:Arial; font-weight: normal;
color:#000000"><font color="#FF0000"><sup>*</sup></font>Last Name:<font color="#FF0000"></font></span></td>
<td valign="top"><input type="text" size="35" name="lname" id="lname" value=""></td></tr>
<tr>
<td height="35" valign="top"><span style="font-size:13px; font-family:Arial; font-weight: normal;
color:#000000">Address: <font color="#FF0000"></font></span></td>
<td valign="top"><textarea cols="28" rows="2" name="address" id="address"></textarea><br><br>
<span id="txt_mobile" style="font-size:11px;"></span></td>
</tr>
<tr>
<td height="35" valign="top"><span style="font-size:13px; font-family:Arial; font-weight: normal;
color:#000000"><font color="#FF0000"><sup>*</sup></font>City:<font color="#FF0000"></font></span></td>
<td valign="top"><input type="text" size="35" name="city" id="city" value=""></td></tr>
<tr>
<td height="35" valign="top"><span style="font-size:13px; font-family:Arial; font-weight: normal;
color:#000000"><font color="#FF0000"><sup>*</sup></font>Contact No:<font color="#FF0000"></font></span></td>
<td valign="top"><input type="text" size="35" name="number" id="number" value=""></td></tr>
<tr>
<td height="35" valign="top"><span style="font-size:13px; font-family:Arial; font-weight: normal;
color:#000000"><font color="#FF0000"><sup>*</sup></font>Email Id:<font color="#FF0000"></font></span></td>
<td valign="top"><input type="text" size="35" name="email" id="email" value=""></td></tr>
<tr>
<td height="35" valign="top"><span style="font-size:13px; font-family:Arial; font-weight: normal;
color:#000000"><font color="#FF0000"><sup>*</sup></font>Position Applied for:<font color="#FF0000"></font></span></td>
<td style="HEIGHT: 21px"><select name="position" id="position" class="formtext">
<option value="">Select</option>
<option value="Trainee Business Development Executive">Trainee Business Development Executive</option>
<option value="Business Development Executive">Business Development Executive</option>
</select>
</td></tr>
<tr>
<td style="WIDTH: 152px" vAlign="top"><span id="Label4" class="text" class="text">
<span style="font-size:13px; font-family:Arial; font-weight: normal;
color:#000000">Current organisation</span></span></td>
<td><input type="text" size="35" name="organization" id="organization" value=""></td>
</tr>
<tr>
<td style="WIDTH: 152px; HEIGHT: 43px" vAlign="top"><span id="Label5" class="text" class="text">
<span style="font-size:13px; font-family:Arial; font-weight: normal;
color:#000000">Designation</span></span></td>
<td style="HEIGHT: 43px"><input type="text" size="35" name="designation" id="designation" value=""></td>
</tr>
<tr>
<td style="WIDTH: 152px; HEIGHT: 23px" vAlign="top"><span lang="EN-GB" style="FONT-FAMILY: 'Times New Roman'; FONT-SIZE: 11pt; mso-fareast-font-family: 'Times New Roman'; mso-ansi-language: EN-GB; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"><span id="Label32" class="text" class="text"><span style="font-size:13px; font-family:Arial; font-weight: normal;
color:#000000">Total
work experience </span></span></span></td>
<td><select name="ExperienceYears" id="ExperienceYears" class="formtext">
<option value=" ">Years</option>
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
<option value="32">32</option>
<option value="33">33</option>
<option value="34">34</option>
<option value="35">35</option>
<option value="36">36</option>
<option value="37">37</option>
<option value="38">38</option>
<option value="39">39</option>
<option value="40">40</option>
</select><select name="ExperienceYears" id="ExperienceMonths" class="formtext">
<option value=" ">Months</option>
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
</select></td>
</tr>
<tr>
<td vAlign="top" width="100%" colSpan="2">
<table id="Table11" cellSpacing="0" cellPadding="1" width="100%" border="0">
<tr>
<td class="text" style="HEIGHT: 15px" vAlign="top"><span style="font-size:13px; font-family:Arial; font-weight: normal;
color:#000000">Resume</span>
</td>
<td vAlign="top"><input name="file" type="file" id="file" class="FormText" />
</td>
</tr>
</table>
</td>
</tr>
<!--<tr>
<td colSpan="2"><span id="Label13" class="text">Enter the text as it is shown in the box below</span></td>
</tr>
<tr>
<td colSpan="2"><img id="Image1" src="../CreateCaptcha.aspx" style="border-width:0px;" /><input name="strCAPTCHA" type="text" maxlength="6" id="strCAPTCHA" class="formtext" style="width:112px;" /></td>
</tr>!-->
<tr>
<td align="center" colSpan="2"><input style="margin-left:50px;" type="submit" value="Submit" class="submit" onclick="return reguser_validation(frm);"/></td>
</tr>
<!-- InstanceEndEditable -->
</table>
</TR>
</TABLE>
</td>
</tr>
<tbody>
</table>
</td>
</tr></td></tr></table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
/*Validations*/
<script type="text/javascript" src="email_validate.js"></script>
<script type="text/javascript" src="signup.js"></script>
<script language="javascript">
function reguser_validation(field)
{
var name = document.frm.name;
var lname = document.frm.lname;
var city = document.frm.city;
var number = document.frm.number;
var email = document.frm.email;
var position = document.frm.position;
if ((name.value == null) || (name.value == ''))
{
alert("Please enter your First name");
name.focus();
return false;
}
/*if(name='!alphabetics')
{
alert("Please enter Alphabets in your First name");
return false;
}*/
if ((lname.value == null) || (lname.value == ''))
{
alert("Please enter your Last name");
lname.focus();
return false;
}
/*if(lname='!alphabetics')
{
alert("Please enter Alphabets in your Last name");
return false;
}*/
if ((city.value == null) || (city.value == ''))
{
alert("Please enter your City name");
city.focus();
return false;
}
/* if(city='!alphabetics')
{
alert("Please enter Alphabets in your city name");
return false;
}*/
if ((number.value == null) || (number.value == ''))
{
alert("Please enter your Contact Number");
number.focus();
return false;
}
if(Mobile_Validate(number) == false)
{
return false;
}
if ((email.value == null) || (email.value == '')){
alert("Please enter your Email ID.");
email.focus();
return false;
}
if (emailcheck(email.value) == false){
alert("Please Enter Valid Email ID.");
email.focus();
return false;
}
if (position.value == '')
{
alert('Please Enter the position that your applying for');
position.focus();
return false;
}
return true;
}
</script>
下面是我的ThankYou.php
<?php
$to = "web@adisysonline.com";
$subject = "Uploaded file";
$fileatt = $_FILES['file']['tmp_name'];
$fileatt_type = $_FILES['file']['type'];
$fileatt_name = $_FILES['file']['name'];
$headers = "From: $from";
if (is_uploaded_file($fileatt))
{
// Read the file to be attached ('rb' = read binary)
$file = fopen($fileatt, 'rb');
$data = fread($file, filesize($fileatt));
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
$headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\"";
$mail_body = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/html; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" . $mail_body . "\n\n";
$data = chunk_split( base64_encode($data));
$mail_body .= "--{$mime_boundary}\n" . "Content-Type: {$fileatt_type};\n" . " name=\"{$fileatt_name}\"\n" . "Content-Disposition: attachment;\n" .
" filename=\"{$fileatt_name}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n" . "--{$mime_boundary}--\n";
if ($_SERVER['REQUEST_METHOD'] == "POST") {
foreach ($_POST as $key => $value) {
$msg .= ucfirst ($key) ." : ". $value . "\n";
}
}
else {
foreach ($_GET as $key => $value) {
$msg .= ucfirst ($key) ." : ". $value . "\n";
}
}
$ok = @mail($to, $subject, $msg, $mail_body, $headers);
if($ok)
echo "<b>Thank you for submitting Your Resume.<br> We will get back to you as soon as possible.</b>";
else
echo "Server Busy please try after few minutes";
fclose($file);
}
?>
而且我还需要知道如何为附件添加病毒检查器以避免任何病毒
任何帮助将是可观的..等待专家回复....