我正在尝试使用 PHP 邮件获取自定义联系表单,让用户附上照片,然后将其发送给 PHP 邮件代码中列出的收件人
<input type="file" id="file" name="file">
表格代码如下;
<form action="register-mail.php" method="POST" enctype="multipart/form-data">
<input type="file" id="file" name="file">
<input type="submit" value="Submit">
</form>
PHP邮件代码如下;
<?php $file = $_FILES['file'];
$formcontent="Email Text Content";
$recipient = "fake@email.com";
$subject = "Here is a Photo";
$mailheader = 'From: Basic Sign-up <fake@email.com>' . "\r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
die();
?>
我似乎无法将文件附加到正在发送的电子邮件中。我究竟做错了什么?