Multiple attachments is just a case of slightly adjusting the exisiting code to deal with the multi-dimensional array:madmike wrote:That is the way it is setup.
handler_form.php
/tmp
/lib/Swift/
Should I move the "/tmp" into the "/lib" folder? Another question, Do you have a tutorial on multiple attachments? I can not get mine to work. If you don't have one, I'll open a new post with my code.
Code: Select all
File 1: <input type="file" name="attachment[]" />
File 2: <input type="file" name="attachment[]" />Code: Select all
if (!empty($_FILES["attachment"])) {
//Each element in $_FILES becomes a multidimensional array
foreach ($_FILES["attachment"]["tmp_name"] as $key => $value) {
if (!$_FILES["attachment"]["error"][$key]) {
$message->attach(new Swift_Message_Attachment(
new Swift_File($value), $_FILES["attachment"]["name"][$key], $_FILES["attachment"]["type"][$key]));
}
}
}