【问题标题】:PHPMailer giving me "noname" attachmentsPHPMailer 给我“无名”附件
【发布时间】:2013-01-07 14:15:56
【问题描述】:

我的问题与this一模一样,我得到的附件没有扩展名,如果我手动将扩展名添加到文件中,文件仍然无法识别。是什么原因造成的?

这是添加附件的部分,其余为标准:

  foreach($_FILES['uploads']['name'] as $key => $file){
    $mail->attachment[] = array($_FILES['uploads']['tmp_name'][$key], $_FILES['uploads']['name'][$key]);
    $mail->boundary = "_b" . md5(uniqid(time()));
  }

编辑:

在每个附件的开头我都会看到:

name="phpmailer.inc.php"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="phpmailer.inc.php"

这正常吗?

编辑: 此外,我将文件复制到服务器并从那里将它们添加到附件中,但所有文件都是“无名”且大小正确。

【问题讨论】:

    标签: php phpmailer email-attachments


    【解决方案1】:

    我认为你不能使用$_FILES['uploads']['tmp_name'][$key] 文件作为附件,因为$_FILES['uploads']['tmp_name'] 是临时文件。

    首先,您需要将该文档/文件上传到服务器,然后将其附加到邮件中。不仅仅是它会起作用。

    【讨论】:

    • 但这意味着我必须手动清空文件夹...而 temp 中的文件应该是相同的文件,或者那里到底发生了什么?
    • @SEROK 只上传带有“move_uploaded_file()”的文件,然后从上传的文件夹而不是临时位置附加。
    猜你喜欢
    • 2012-08-17
    • 1970-01-01
    • 2011-10-05
    • 2011-09-13
    • 2014-08-14
    • 2016-10-28
    • 2013-05-22
    • 2017-12-05
    • 2017-04-29
    相关资源
    最近更新 更多