Problem with Multiple Attachments
Posted: Sun Mar 23, 2008 3:24 pm
I've followed the setup process for "Sending an e-mail from a form with Swift" to a T and it works beautifully! Being a guy who has very very little PHP experience (I refer to it as "the language with the dollar signs everywhere") I had very little trouble customizing the areas I needed to in order for the form mailer to do what I wanted it to do... EXCEPT! ... sending mutliple attachments.
I can get it to send ONE attachment just fine and I was ecstatic about that but I need it to send three. I will say I searched and searched these forums and found this:
viewtopic.php?f=52&t=67221&st=0&sk=t&sd ... s&start=15
post but I'll be honest, i really don't know what it's telling me to do. If anyone can help me understand this or show me a way to make the "Sending an e-mail from a form with Swift" work for multiple attachments I'd greatly appreciate it. here is the sections of code that I've deduced (great commenting with the code by the way) is dealing with the file attachments:
I hope I've asked the question correctly and shown you the code properly. Thanks.
viewtopic.php?f=52&t=67221&st=0&sk=t&sd ... s&start=15
post but I'll be honest, i really don't know what it's telling me to do. If anyone can help me understand this or show me a way to make the "Sending an e-mail from a form with Swift" work for multiple attachments I'd greatly appreciate it. here is the sections of code that I've deduced (great commenting with the code by the way) is dealing with the file attachments:
Code: Select all
<input type="file" name="attachment" /><input type="file" name="attachment" /><input type="file" name="attachment" /> Code: Select all
//Check if an attachment was uploaded
$file_path = false;
$file_name = false;
$file_type = false;
if (!empty($_FILES["attachment"]["tmp_name"]))
{
if ($_FILES["attachment"]["error"])
{
//Redirect if the upload has failed
header("Location: ./form.php?error=upload_failed");
exit();
}
$file_path = $_FILES["attachment"]["tmp_name"];
$file_name = $_FILES["attachment"]["name"];
$file_type = $_FILES["attachment"]["type"];
}
//second part of php
//If an attachment was sent, attach it
if ($file_path && $file_name && $file_type)
{
$message->attach(
new Swift_Message_Attachment(new Swift_File($file_path), $file_name, $file_type));
}