phpMailer attachment

前端 未结 7 1961
时光取名叫无心
时光取名叫无心 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条回答
  •  旧时难觅i
    2020-12-06 09:27

    I have been able to solve this problem with using an counter:

    $locatie = 'uploads/';
    $upload_count = -1;
    
        for ($i = 0; $i <= 2; $i++)
        {
            if($_FILES['uploaded'.$i]['type'] != 'application/octet-stream')  // Geen php files
            {
                $folder = $locatie.basename($_FILES['uploaded'.$i]['name']) ;           
                if(move_uploaded_file($_FILES['uploaded'.$i]['tmp_name'], $folder))
                {
                    $upload_count ++;
                }
            }
    

    Loop for the attachment:

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

提交回复
热议问题