I have add the code to my own form but I have this error:
"No attachment detected".
I am not a developer, so I'm a little confuse when I talk about code, sorry for that :(
This is my code:
<label for="cv">Votre votre CV
<span class="obligatoire">*</span>
</label>
<input type="file" class="validate[required,custom[cv]]" name="cv" class="cv" value="Votre CV au format PDF ou word uniquement" />
and the code in reception:
$allowedExts = array("doc", "docx", "pdf");
$temp = explode(".", $_FILES["cv"]["name"]);
$extension = end($temp);
if ((($_FILES["cv"]["type"] == "application/pdf")
|| ($_FILES["cv"]["type"] == "application/msword"))
&& in_array($extension, $allowedExts))
{
if ($_FILES["cv"]["error"] > 0)
{
echo "<script>alert('Error: " . $_FILES["cv"]["error"] ."')</script>";
}
else
{
$d='telechargements/emploi/cv/';
$de=$d . basename($_FILES['cv']['name']);
move_uploaded_file($_FILES["cv"]["tmp_name"], $de);
$fileName = $_FILES['cv']['name'];
$filePath = $_FILES['cv']['tmp_name'];
//add only if the file is an upload
}
}
else
{
echo "<script>alert('Invalid file')</script>";
}
$mail = new PHPMailer();
$mail->IsMail();
$mail->AddReplyTo($_POST['email']);
$mail->AddAddress($emailAddress);
$mail->SetFrom($_POST['email']);
$mail->Subject = "Site Collin : Une réponse à l'offre de ".mb_strtolower($_POST['job'])."";
$mail->AddAttachment($_FILES['cv']['tmp_name'], $_FILES['cv']['name']);
For me, there is no error, so I don't understand why the file is not detected during the post.
Somebody can help me?
Thanks a lot!