hi i’ve got question i’ve made simple form with attachment input and i want to send this attachment via mail in to my mailbox but i allways see the error that attached file isn;t found on filesystem.
this is the code in 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);
}
?>
what i’m doing wrong ?
@arclite: Since you are getting attachment not found error.
Check your upload folder permission and make it writable if not.
@pari: Since he is using “require” the php will throw an error if the required file doesn’t exit. So it cannot be a problem.