PHPmailer正在发送格式未知的附件文件

PHPmailer正在发送格式未知的附件文件,php,phpmailer,Php,Phpmailer,?> 和html代码 <?php $file = $_FILES["file"]["tmp_name"]; $file1 = $_FILES["file1"]["tmp_name"]; $attachment_path = $file; $attachment_path1 = $file1; $body = "some text"; include("class.phpmailer.php"); //Create

?>

和html代码

<?php
$file           =   $_FILES["file"]["tmp_name"];
$file1          =   $_FILES["file1"]["tmp_name"];

$attachment_path    =   $file;
$attachment_path1   =   $file1;

$body   = "some text";

include("class.phpmailer.php");

//Create a new PHPMailer instance
$mail = new PHPMailer();
//Set who the message is to be sent from
$mail->SetFrom('mail@example.com', $username);
//Set who the message is to be sent to
$mail->AddAddress('mail@example.com', 'Ticket Relief');
//Set the subject line
$mail->Subject = 'Inquiry from website by Form Fillup';
//Replace the plain text body with one created manually
$mail->Body = $body;
//Attach an image file
$mail->AddAttachment($attachment_path, "attachment1", "base64", "application/octet-stream");
$mail->AddAttachment($attachment_path1, "attachment1", "base64", "application/octet-stream");

//Send the message, check for errors
if(!$mail->Send()) {
  echo "Mailer Error: " . $mail->ErrorInfo;
} else {
  echo "Email has been sent! Please <a href='index.php'>Click Here </a> to go back to home page";
}
我正在接收电子邮件,但无法打开附件。它的格式未知。 如果文件大小超过200kb,则发送邮件需要40-45秒;如果文件大小超过600kb,则处理邮件需要1分钟以上
需要关于这些问题的帮助

首先,验证上载是否确实成功。试试这个:

<form action="functions.php" method="post" enctype="multipart/form-data">

                   <div class="outer1">
                        <label> Please Choose File</label>
                        <input type="file" class="span4" name="file">
                    </div>
                    <div class="outer1">
                        <label> Please Choose File</label>
                        <input type="file" class="span4" name="file1">
                    </div>                     
                   <div class="outer1">
                        <input type="submit" class="submit btn btn-success btn-large pull-right" value="Submit">
                   </div>
                </form>         
您应该将文件名设置为第二个参数,而不仅仅是像attachment1这样的字符串

if(isset($_FILES['file']) && $_FILES['file']['error'] == UPLOAD_ERR_OK && 
   isset($_FILES['file1']) && $_FILES['file1']['error'] == UPLOAD_ERR_OK

) {
  $mail->AddAttachment($_FILES['file']['tmp_name'], $_FILES['file']['name']);
  $mail->AddAttachment($_FILES['file1']['tmp_name'], $_FILES['file1']['name']); 
}
else {
  // Do something else, upload is not successful
}
AddAttachment($path, $filename, ...
                      //^ put here the file name like $_FILES['file1']['name']