您好我有問題,我已經使附件輸入簡單的形式,我想通過郵件發送這個附件到我的郵箱,但我總是看到錯誤附加文件isn;噸在文件系統上找到。PHPmailer和附件的形式 - 不發送
這是在PHP代碼:
<?
require('phpmailer/phpmailer.inc.php');
$mail = new PHPMailer();
$mail->From= $_POST['email'];
$mail->FromName= $_POST['contact'];
$mail->Sender= $_POST['email'];
$mail->AddReplyTo("xxxx", "Porozumienie");
$mail->AddAddress("xxxxx");
$mail->Subject = "Your invoice";
$mail->IsHTML(false);
$plik_tmp = $_FILES[contr][tmp_name];
$plik_nazwa = $_FILES[contr][name];
$plik_rozmiar = $_FILES[contr][size];
$target_path = "uploads/";
$target_path = $target_path . basename($_FILES['contr']['name']);
if(move_uploaded_file($_FILES['contr']['tmp_name'], $target_path)) {
echo "The file ". basename($_FILES['contr']['name']).
" has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
$mail->AddAttachment(basename($target_path));
$mail->Body = "Please find your invoice attached.";
if(!$mail->Send())
{
echo "Error sending";
}
else
{
echo "Letter is sent";
unlink($target_path);
}
?>
什麼,我做錯了什麼?
在require('phpmailer/phpmailer.inc.php')中檢查你的路徑。如果你的文件在其他文件夾中,那麼你應該寫require('../ phpmailer/phpmailer.inc.php')。 – Dhruvisha