I have a phpmailer that attaches files by looping through an array of files from an file input field. How can i make it so that onl PDF or DOC are allowed. And if something else is attempted, the script stope and gives an error: "File type not supported. Only PDF or DOC."
Any suggestions? Heres my current script;
foreach(array_keys($_FILES['files']['name']) as $key) {
$source = $_FILES['files']['tmp_name'][$key];
$filename = $_FILES['files']['name'][$key];
$mail->AddAttachment($source, $filename);
}