Reputation: 175
I have a little function, which supposed to be sending an email with the submitted image as attachment. I receive the email, that's okay, but the attachment is missing. The PHPMailer isn't trowing any errors, so I don't know what could be the problem.
This is the actual code:
if(isset($_FILES['submitimg']['name'])){
$messageBody .= "<p>Bla bla bla:</p>";
$messageBody .= "<p>Bla name: ".$_POST['submitname']."</p>";
$messageBody .= "<p>Bla email: ".$_POST['submitemail']."</p>";
$mail = new PHPMailer();
$mail->CharSet = 'UTF-8';
$mail->setFrom('[email protected]', 'Bla bla');
$mail->addAddress($adminEmail, $adminName);
$mail->Subject = 'New blabla';
$mail->Body = $messageBody;
$fileName = $_FILES['submitimg']['name'];
$filePath = $_FILES['submitimg']['tmpname'];
$mail->addAttachment($filePath, $fileName);
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
}
}
Can someone help me out, please? :)
Thank you very much!
Upvotes: 0
Views: 98
Reputation: 175
Okay, I found the solution. It was a simple typo:
$filePath = $_FILES['submitimg']['tmp_name'];
Upvotes: 2