我希望能够将文件附加到外发电子邮件。我在一个名为 upload.php 的单独文件中提供了如何执行此操作的代码,但我想知道是否可以将其全部放入 index.php,因为 index 是表单操作指向的位置。我只是不确定将它放在索引中的哪个位置以便它可以工作......
此代码来自 index.php 部分(其中 $action = send-message):
case 'send-message':
if(send_message($to, $cc, $subject, $message)) {
echo "<p style=\"padding-bottom: 100px\">Message sent!</p>";
} else {
echo "<p style=\"padding-bottom: 100px\">Could not send message.</p>";
}
break;
然后我有以下代码,它显示了制作新消息的表单(output.php):
<table cellpadding="4" cellspacing="0" border="0" width="<?php echo $table_width; ?>">
<form action="index.php?action=send-message" method="post">
<tr>
<td bgcolor="#cccccc">To Address:</td>
<td bgcolor="#cccccc">
<input type="text" name="to" value="<?php echo $to; ?>" size="60" />
</td>
</tr>
<tr>
<td bgcolor="#cccccc">CC Address:</td>
<td bgcolor="#cccccc">
<input type="text" name="cc" value="<?php echo $cc; ?>" size="60" />
</td>
</tr>
<tr>
<td bgcolor="#cccccc">Subject:</td>
<td bgcolor="#cccccc">
<input type="text" name="subject" value="<?php echo $subject; ?>" size="60" />
</tr>
<tr>
<td bgcolor="#cccccc">Upload a file:</td>
<td bgcolor="#cccccc">
<input type="hidden" name="MAX_FILE_SIZE" value="1000000" />
<input type="file" name="userfile" id="userfile"/>
<input type="submit" value="Attach File">
</td>
</tr>
<tr>
<td colspan="2" bgcolor="#cccccc">
<textarea name="message" rows="10" cols="72"><?php echo $message; ?></textarea>
</td>
</tr>
<tr>
<td colspan="2" align="center" bgcolor="#cccccc">
<?php display_form_button('send-message'); ?>
</td>
</tr>
</form>
</table>
我希望这是有道理的,不会太混乱!谢谢您的帮助!