如何使用phpmailer添加多个附件

时间:2019-02-06 10:24:43

标签: php arrays loops email

我正在尝试将多个附件从表单添加到电子邮件中。添加一个有效,但是当向我的表单添加多个文件时,不再有附件。

如果我在邮件中打印 pcl::IndicesClustersPtr clusters(new pcl::IndicesClusters); clusters->push_back( (*clusters2)[j]) //seems to be okay clusters->erase(i); // Nope (*clusters).erase(i); // Nope pcl::PointIndices empty_indices; // compiles but results not as expected (*clusters)[i] = empty_indices; ,这就是我看到的:

$_FILES

具有两个文件的数组,因此看起来正确。我试图像这样循环该数组:

Array
(
    [attachmentFile] => Array
        (
            [name] => Array
                (
                    [0] => logo.png
                    [1] => snmicon.png
                )

            [type] => Array
                (
                    [0] => image/png
                    [1] => image/png
                )

            [tmp_name] => Array
                (
                    [0] => /tmp/phpEGhzM5
                    [1] => /tmp/php63XC91
                )

            [error] => Array
                (
                    [0] => 0
                    [1] => 0
                )

            [size] => Array
                (
                    [0] => 7809
                    [1] => 2088
                )

        )

)

但这不起作用。

但是当我不循环数组并像这样键入它时,它确实起作用:

foreach($_FILES as $bestand){
    $mail->AddAttachment($bestand['attachmentFile']['tmp_name'],$bestand['attachmentFile']['name']);
}

那是为什么?

如何添加多个附件?

0 个答案:

没有答案