我试图让一个 php 邮件程序代码附加一个文件以及常规信息。我不知道该怎么办。这是我已经走了多远。
表单.html
<form method="post" name="contact" action="contactprocessor.php">
<label for="name">Name: </label> <input type="text" id="name">
<label for="email">email: </label> <input type="email" id="email">
<label for="file">Upload file: </label> <input type="file" id="file">
<input type="submit" id="name" value="upload">
联系人处理器.php
<?php
$emailSubject = 'file upload';
$mailto ='me@mymail.com';
$nameField = $_POST['name'];
$emailField = $_POST['email'];
$body = <<<EOD
NAME: $name <br>
Email: $email <br>
EOD;
$headers = "from: $email\r\n";
$success = mail($mailto, $emailSubject, $body, $headers);
?>