I am trying to create a webform that has 4 upload field. I want to have the uploaded file email to me with phpmailer. I need to know how to validate that the uploaded files are images, attached via phpmailer and send to an email address. I found the below code that will move the file to a folder but I want to attached the files to email without moving them. Is that possible and how do I do it? Any help will be much appreciated.
$target_path = "uploads/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']).
" has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
$mail->AddAttachment($target_path);