phpMailer attachment

前端 未结 7 1953
时光取名叫无心
时光取名叫无心 2020-12-06 08:55

I\'m using this to attach files to an mail after uploading them to my server:

for ($i = 0; $i <= 2; $i++)
{
    $mail->AddAttachment($locatie.$_FILES[\         


        
7条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-06 09:31

    You need to check if that file was actually uploaded/exists before adding the attachment. Something like

    for ($i = 0; $i <= 2; $i++)
    {
        if (file_exists($locatie.$_FILES['uploaded'.$i]['tmp_name'])) {
            $mail->AddAttachment($locatie.$_FILES['uploaded'.$i]['tmp_name'], $_FILES['uploaded'.$i]['name']);
        }
    }
    

提交回复
热议问题