Я новичок в PHP. Я пытаюсь получить два файла, которые загружаются из формы в электронное письмо, чтобы отправить мне. Это, вероятно, легко, но у меня нет последних трех часов.Прикрепите два файла из формы по электронной почте
Мне удалось получить информацию о файле, как вы видите. Как вы их присоединяете? Вот где у меня проблемы.
Это код, который получает два файла (и другие данные) из формы. Сайт является SermonPublish.com, если это полезно.
Спасибо за любую помощь.
Стандарт получает переменные.
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$cover = "cover: " . test_input($_POST["cover"]) . "\n";
$authorname = "Author Name: " . test_input($_POST["authorName"]) . "\n";
$booktitle = "Title: " . test_input($_POST["bookTitle"]) . "\n";
$subtitle = "Subtitle: " . test_input($_POST["subtitle"]) . "\n";
$description = "Description: " . test_input($_POST["description"]) . "\n";
$aboutauthor = "About Author: " . test_input($_POST["aboutAuthor"]) . "\n";
$clientnumber = "Client Number: " . test_input($_POST["clientNumber"]) . "\n";
$payment = "Payment: " . test_input($_POST["payment"]) . "\n";
$address = "Address: " . test_input($_POST["address"]) . "\n";
$agreement = "Agree: " . test_input($_POST["agreement"]) . "\n";
$email = test_input($_POST["email"]);
Получить информацию о загрузке файла.
//Get the uploaded file information
$author_photo_name =
basename($_FILES['authorPhoto']['name']);
$author_photo_type =
substr($author_photo_name,
strrpos($author_photo_name, '.') + 1);
$author_photo_size =
$_FILES["authorPhoto"]["size"]/1024;//size in KBs
//Get the uploaded file information
$sermon_name =
basename($_FILES['sermon']['name']);
$sermon_type =
substr($sermon_name,
strrpos($sermon_name, '.') + 1);
$sermon_size =
$_FILES["sermon"]["size"]/1024;//size in KBs
}
Хорошо, теперь как вы прикрепляете?
Стандартный почтовый код
$subject = "Sermon Submission";
$message = $cover . $authorname . $booktitle . $subtitle . $description . $aboutauthor . $clientnumber . $payment . $address . $agreement . $email;
$message = wordwrap($message, 70);
// send mail
mail("[email protected]",$subject,$message,"From: $email\n");
echo "Thank you for your submission. We will contact you as soon as it is processed.";
?>
Адрес электронной почты php() довольно ограниченный доступ к библиотеке, такой как phpmailer. – 2014-09-10 01:08:46