我正在尝试将两个文件附加到一封电子邮件中(请参阅下面的代码),但我只在收到的电子邮件中收到其中一封。
if(isset($_POST['submits']))
{
//The form has been submitted, prep a nice thank you message
$output = '<h1>Thanks for your file and message!</h1>';
//Set the form flag to no display (cheap way!)
$flags = 'style="display:none;"';
//Deal with the email
$to = 'info@domain.org';
$subject = 'cv and image upload';
$message = strip_tags($_POST['message']);
$attachment = chunk_split(base64_encode(file_get_contents($_FILES['file']['tmp_name'])));
$filename = $_FILES['file']['name'];
$boundary =md5(date('r', time()));
$headers = "From: info@domain.org\r\nReply-To: info@domain.org";
$headers .= "\r\nMIME-Version: 1.0\r\nContent-Type: multipart/mixed; boundary=\"_1_$boundary\"";
$message="This is a multi-part message in MIME format.--_1_$boundaryContent-Type: multipart/alternative; boundary=\"_2_$boundary\"--_2_$boundaryContent-Type: text/plain; charset=\"iso-8859-1\"Content-Transfer-Encoding: 7bit$message--_2_$boundary----_1_$boundaryContent-Type: application/octet-stream; name=\"$filename\" Content-Transfer-Encoding: base64 Content-Disposition: attachment $attachment--_1_$boundary--";
mail($to, $subject, $message, $headers);
}
答案 0 :(得分:0)
尝试使用javascript为表单添加更多具有不同名称的文件输入。如果ui不重要,您可以使用更多输入。 你不能一次上传同一输入的两个文件。 并最终使用smtp insted mail()。