嗨,我有一个问题,我用附件输入制作了简单的表格,我想通过邮件将此附件发送到我的邮箱,但我总是看到附件文件未在文件系统上找到的错误。
这是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);
}
?>
我做错了什么?