diff --git a/src/Mailer.php b/src/Mailer.php index e8a3654..e11cbc9 100644 --- a/src/Mailer.php +++ b/src/Mailer.php @@ -70,6 +70,10 @@ public function send(Submission $submission, bool $runValidation = true): bool if ($submission->attachment !== null) { $allowedFileTypes = Craft::$app->getConfig()->getGeneral()->allowedFileExtensions; + if (!is_array($submission->attachment)) { + $submission->attachment = [$submission->attachment]; + } + foreach ($submission->attachment 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'); } } diff --git a/src/models/Submission.php b/src/models/Submission.php index 750b85d..2384974 100644 --- a/src/models/Submission.php +++ b/src/models/Submission.php @@ -39,8 +39,8 @@ class Submission extends Model public $message; /** - * @var UploadedFile[]|null[]|null - * @phpstan-var array|null + * @var UploadedFile|UploadedFile[]|null[]|null + * @phpstan-var UploadedFile|array|null */ public $attachment;