Quantcast
Viewing all articles
Browse latest Browse all 14700

phpmailer attachment file not found

Boa tarde, não estou a conseguir enviar um email com o phpmailer alguém me pode ajudar?   Image may be NSFW.
Clik here to view.
:confused:


PHP (inscricao.php)
Código (PHP):
<?php
require_once('PHPMailer/class.phpmailer.php');
$mail = new PHPMailer(true);
$mail->IsSMTP();

$mail->SMTPDebug = 2;
$mail->SMTPAuth = true;
$mail->SMTPSecure = "tls";
$mail->Host     = "smtp.gmail.com";
$mail->Port     = 587; //ou 465
$mail->Username = "xxxx@gmail.com";
$mail->Password = "yyyy";

$mail->AddAddress('xxxx@gmail.com', 'Inscrição');

$mail->SetFrom('xxxx@gmail.com', 'Inscrição');

$mail->Subject = 'Inscrição';

$mail->Body = "Inscrição/n
Nome : ".$_REQUEST["Nome_1"]."\n\n
    Email : ".$_REQUEST["Email_2"]."\n\n
    NIF: ".$_REQUEST["NIF_3"]."\n\n;
    BI / CC: ".$_REQUEST["BI_CC_4"]."\n\n
    Telemóvel : ".$_REQUEST["Telemóvel_5"]."\n\n
    Equipa: ".$_REQUEST["Equipa_6"]."\n\n";
    
    
$mail->AddAttachment($_REQUEST["upload_7"]);
// Envia o e-mail
$enviado = $mail->Send();
if (!$enviado){
echo "Erro: " . $mail->ErrorInfo;
} else {
echo "Inscrição enviada!";
}
?>
 

HTML (index.php)
Código :
<script language="Javascript">
function validate(){
var allok = true;
if(inscricao_a.Nome_1.value == ""){
alert("Nome inválido");
return false;
}
else{
document.inscricao_a.Submit.disabled="disabled";
return true;
}
</script>

<p>Inscrição</p>

<form name="inscricao_a" method="Post" action="inscricao.php" onsubmit="return validate();">
<table width="100%" border="0" cellpadding="5" cellspacing="0">
<tr><td>Nome:</td><td><input type="edit" name="Nome_1" placeholder="Nome completo" value="" size="50"></td></tr>
<tr><td>Email:</td><td><input type="edit" name="Email_2" placeholder="Email" value="" size="50"></td></tr>
<tr><td>NIF:</td><td><input type="edit" name="NIF_3" placeholder="NIF" value="" size="50"></td></tr>
<tr><td>BI / CC:</td><td><input type="edit" name="BI_CC_4" placeholder="BI ou CC" value="" size="50"></td></tr>
<tr><td>Telemóvel:</td><td><input type="edit" name="Telemóvel_5" placeholder="Telemóvel" value="" size="50"></td></tr>
<tr><td>Equipa:</td><td><input type="edit" name="Equipa_6" placeholder="Nome equipa" value="" size="50"></td></tr>

<tr><td> &nbsp; </td></tr>
<tr><td>Anexar bilhete caducado:</td><td><input type='file' name="upload_7" accept='application/pdf, image/jpeg' ></td></tr>
<tr><td> &nbsp; </td></tr>


<tr><td align="right">
<input type="reset" name="Reset" value="limpar dados"></td><td align="left"><input type="submit" name="Submit" value="Enviar">
</td></tr>
</table></form>

ERRO:

Uncaught exception 'phpmailerException' with message 'Could not access file: scan.jpg' in C:\wamp\www\teste\PHPMailer\class.phpmailer.php

acho que deve ser assim:
$mail->AddAttachment('localização do ficheiro', 'formato'); mas não estou a conseguir nenhum valor correcto a partir do <input type='file' name="upload_7"

Viewing all articles
Browse latest Browse all 14700

Trending Articles