I am using the below script to validate if the uploaded files are pdf and if it is send it with phpmailer. I did not received any error message even when I attached non pdf file . Also, it send the email without attachment. Please help.

PHP Code:
    ob_start();
    require(
"class.phpmailer.php");

    if(isset(
$_FILES['upload']['tmp_name'])){
    
$finfo finfo_open(FILEINFO_MIME_TYPE);
    
$mime=finfo_file($finfo$_FILES['upload']['tmp_name']);
    if(
$mime=='application/pdf'){
           }}

    
$message "some message";
    
$mail = new PHPMailer();
    
$mail->From     = ('sample@youdomain.net');
    
$mail->AddAddress=('sample@youdomain.net');
    
$mail->Subject  "Submitted files";
    
$mail->Body     $message;
    
$mail->WordWrap 50;

    foreach(
$_FILES['upload']['tmp_name'] as $upload
    if(!empty(
$upload)) {
    
$mail->AddAttachment($upload);
    }
    
$mail->Send();

    
header("Location: thankyou.php");
    exit();     
    }}