我想这样做,以便我可以将文件字段“图像”中指定的图像附加到我的表单发送的电子邮件中。我可以在这里添加什么来做到这一点?我很感激帮助。如果一切顺利,它应该向我发送一条带有指定信息和图像附件的消息。
<?php
if ($_POST["email"]<>'') {
$ToEmail = 'skidberna@yahoo.com';
$EmailSubject = 'Contact form from Legendmaker Customer: ' .$_POST["email"];
$mailheader = "From Legendmaker Customer: ".$_POST["name"]."\r\n";
$mailheader .= "Reply-To: ".$_POST["name"]."\r\n";
$mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n";
$MESSAGE_BODY = "Name: ".$_POST["name"]." ";
$MESSAGE_BODY .= "Email: ".$_POST["email"]." ";
$MESSAGE_BODY .= "Recipient's Gender: ".nl2br($_POST["gender"])." ";
$MESSAGE_BODY .= "Recipient's Name: ".$_POST["recipientname"]." ";
$MESSAGE_BODY .= "Recipient's Hobbies/Interests: ".nl2br($_POST["hobbies"])." ";
$MESSAGE_BODY .= "Recipient's Age: ".$_POST["age"]." ";
$MESSAGE_BODY .= "Other Information: ".nl2br($_POST["otherinfo"])." ";
mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure");
?>
<title>The Legend Maker - submit a story (test server)</title>
<link href="/CSS/CSS.css" rel="stylesheet" type="text/css">
<div align="center">
<p><span class="linkText"><a href="/index.html">Home</a>
<a href="/contact-us.php">Contact Us</a>
<a href="/payments.html">Payments</a> </span> </p>
<p> </p>
<h2 class="headingText"> </h2>
<h2 class="headingText"> </h2>
<h2 class="headingText"> </h2>
<h2 class="headingText">(for testing purposes)</h2>
<h2 class="headingText">Submit a story test server</h2>
</div>
<p>Your story request was submitted
<?php
}
else
{
?>
</p>
<title>The Legend Maker - submit a story (test server)</title>
<link href="/CSS/CSS.css" rel="stylesheet" type="text/css">
<div align="center">
<p><span class="linkText">
<a href="/index.html">Home</a>
<a href="/contact-us.php">Contact Us</a>
<a href="/payments.html">Payments</a></span> </p>
<p> </p>
<h2 class="headingText"> </h2>
<h2 class="headingText"> </h2>
<h2 class="headingText"> </h2>
<h2 class="headingText">(for testing purposes)</h2>
<h2 class="headingText">Submit a story test server</h2>
</div>
<form action="submit-story-with-attach.php" method="post" enctype="multipart/form-data">
<table width="476" height="468" border="0" cellpadding="0" cellspacing="2">
<tr>
<td width="23%" height="25" class="bodytext"><p align="center">Your Name:</p></td>
<td width="77%"><input name="name" type="text" id="name" size="32"></td>
</tr>
<tr>
<td height="25" class="bodytext"><p align="center">Email Address:</p></td>
<td><input name="email" type="text" id="email" value="you@example.com" size="32"></td>
</tr>
<tr>
<td height="44" class="bodytext"><p align="center">Recipient's Gender:</p></td>
<td><label>
<select name="gender" id="gender">
<option value="male" selected="selected">Male</option>
<option value="female">Female</option>
<option value="other">Other</option>
</select>
</label></td>
</tr>
<tr>
<td height="44" class="bodytext"><p align="center">Recipient's Name:</p> </td>
<td align="left" valign="top"><input name="recipientname" type="text" id="recipientname" value="ex: Jonny" size="32" /></td>
</tr>
<tr>
<td height="44" class="bodytext"><p align="center">Recipient's Interests or Hobbies: </p></td>
<td align="left" valign="top"><textarea name="hobbies" cols="50" rows="6" id="hobbies">ex: horseback riding, biking...</textarea></td>
</tr>
<tr>
<td class="bodytext"><p align="center">Recipient's Age:</p></td>
<td align="left" valign="top"><input name="age" type="text" id="age" size="5" maxlength="3" /></td>
</tr>
<tr>
<td class="bodytext"><p align="center">Other Important Information:</p></td>
<td align="left" valign="top"><textarea name="otherinfo" cols="50" rows="6" id="otherinfo">ex: other things the recipient may enjoy or their favorite superhero
Please specify information you are giving us also: don't do this: superman
submit it like this: favorite superhero: superman</textarea></td>
</tr>
<tr>
<td class="bodytext"><p align="center">Images You Would Like To Include In Story:</p> </td>
<td align="left" valign="top"><label>
<br />
<input type="file" name="image" id="image" />
</label></td>
</tr>
<tr>
<td class="bodytext"><p align="center"> </p></td>
<td align="left" valign="top"><input type="submit" name="Submit" value="Send" /></td>
</tr>
</table>
</form>
<?php
};
?>