phpMailer attachment

前端 未结 7 1959
时光取名叫无心
时光取名叫无心 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:28

    Solution

    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']);
        }
    }
    

    Update

    You were using $locatie.$_FILES['uploaded'.$i]['name'] instead of $locatie.$_FILES['uploaded'.$i]['tmp_name'] as the file to load. When a file is uploaded it is renamed with a temporary name and placed on the temporary folder. That's where you will get it, and that's why you need to reference it with $locatie.$_FILES['uploaded'.$i]['tmp_name']

提交回复
热议问题