I am a newbie with PHP. I'm trying to get two files that upload from a form into an email to send to myself. This is probably easy, but haven't got it the last three hours.
I've managed to get file information as you see. How do you attach these? That's where I'm having trouble.
This is the code that is receiving the two files (and other data) from the form.. The site is SermonPublish.com if that is helpful.
Thanks for any help.
Standard get the variables.
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$cover = "cover: " . test_input($_POST["cover"]) . "
";
$authorname = "Author Name: " . test_input($_POST["authorName"]) . "
";
$booktitle = "Title: " . test_input($_POST["bookTitle"]) . "
";
$subtitle = "Subtitle: " . test_input($_POST["subtitle"]) . "
";
$description = "Description: " . test_input($_POST["description"]) . "
";
$aboutauthor = "About Author: " . test_input($_POST["aboutAuthor"]) . "
";
$clientnumber = "Client Number: " . test_input($_POST["clientNumber"]) . "
";
$payment = "Payment: " . test_input($_POST["payment"]) . "
";
$address = "Address: " . test_input($_POST["address"]) . "
";
$agreement = "Agree: " . test_input($_POST["agreement"]) . "
";
$email = test_input($_POST["email"]);
Get details about the file uploads.
//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
}
Okay, now how do you attach?
Standard mailing code
$subject = "Sermon Submission";
$message = $cover . $authorname . $booktitle . $subtitle . $description . $aboutauthor . $clientnumber . $payment . $address . $agreement . $email;
$message = wordwrap($message, 70);
// send mail
mail("wibberding@gmail.com",$subject,$message,"From: $email
");
echo "Thank you for your submission. We will contact you as soon as it is processed.";
?>