diff --git a/src/Mailer.php b/src/Mailer.php index e8a3654..a179312 100644 --- a/src/Mailer.php +++ b/src/Mailer.php @@ -70,7 +70,8 @@ public function send(Submission $submission, bool $runValidation = true): bool if ($submission->attachment !== null) { $allowedFileTypes = Craft::$app->getConfig()->getGeneral()->allowedFileExtensions; - foreach ($submission->attachment as $attachment) { + $attachments = is_array($submission->attachment) ? $submission->attachment : [$submission->attachment]; + foreach ($attachments as $attachment) { if (!$attachment) { continue; } diff --git a/src/controllers/SendController.php b/src/controllers/SendController.php index d263d5f..bc446b4 100644 --- a/src/controllers/SendController.php +++ b/src/controllers/SendController.php @@ -47,7 +47,7 @@ public function actionIndex() if (is_array($_FILES['attachment']['name'])) { $submission->attachment = UploadedFile::getInstancesByName('attachment'); } else { - $submission->attachment = [UploadedFile::getInstanceByName('attachment')]; + $submission->attachment = UploadedFile::getInstanceByName('attachment'); } }