Attached file is not sent in the feedback form

Tried to create a feedback form from the site. Read a bunch of PHP books, downloaded a bunch of event handlers. But I did not achieve that the attached file would be sent to e-mail. All form fields work fine except for one. Experts, tell me where is the mistake? Thank you in advance.

And one more thing. Is the class.phpmailer.php class available on the server or does it need to be installed?

Shape file:

<div align="center" id="mail_form"><br><br>
<form method="post" action="formmail.php" enctype="multipart/form-data">
<input type="hidden" name=recipient value="[email protected]">
<input type="hidden" name="subject" value="in-Site">
 <table width="800">
  <tr><td height="20"></td></tr>
  <tr><td align="center">
   <fieldset title=" ">
   <legend aligen="left"> </legend>
<table>
 <tr><td height="10"></td><td></td><td></td></tr>
 <tr><td align="right"><label for="opinion-file"> :&nbsp;&nbsp;</label></td><td width="20"></td><td><input type="file" name="opinion-file" size="75"></td></tr>
 <tr><td height="10"></td><td></td><td></td></tr>
 <tr><td align="right" valign="top">:</td><td width="20"></td><td><textarea cols="61" rows="10" name="message"></textarea></td></tr>
 <tr><td height="10"></td><td></td><td></td></tr>
</table>
 <input type="submit" value=" ">
 <input type="reset" value=" ">
   </fieldset><br>
  </td></tr>
 </table>
</form>
</div>

External event handler:

<?php
function complete_mail() {
    $_POST['title'] =  substr(htmlspecialchars(trim($_POST['title'])), 0, 1000);
    $_POST['mess'] =  substr(htmlspecialchars(trim($_POST['mess'])), 0, 1000000);
    $_POST['name'] =  substr(htmlspecialchars(trim($_POST['name'])), 0, 30);
    $_POST['tel'] =  substr(htmlspecialchars(trim($_POST['tel'])), 0, 30);
    $_POST['email'] =  substr(htmlspecialchars(trim($_POST['email'])), 0, 50);
    //     "" -   0
    if (empty($_POST['name']))
         output_err(0);
    //     email -   1
    if(!preg_match("/[0-9a-z_][email protected][0-9a-z_^\.]+\.[a-z]{2,3}/i", $_POST['email']))
         output_err(1);
    //     "" -   2
    if(empty($_POST['mess']))
         output_err(2);
    //  ,      ,   html  ;-)
    $mess = '
<b> :</b>'.$_POST['name'].'<br />
<b> :</b>'.$_POST['tel'].'<br />
<b> email:</b>'.$_POST['email'].'<br />
'.$_POST['mess'];
    //      
    require 'class.phpmailer.php';
    $mail = new PHPMailer();
    $mail->From = '[email protected]';      //  
    $mail->FromName = 'www.php-mail.ru';   //  
    $mail->AddAddress('[email protected]', ''); //  - , 
    $mail->IsHTML(true);        //    HTML
    $mail->Subject = $_POST['title'];  //  
    //   ,     
    if(isset($_FILES['attachfile'])) {
             if($_FILES['attachfile']['error'] == 0){
                $mail->AddAttachment($_FILES['attachfile']['tmp_name'], $_FILES['attachfile']['name']);
             }
    }
    //   ,         .
    if(isset($_FILES['attachimage'])) {
             if($_FILES['attachimage']['error'] == 0){
                if (!$mail->AddEmbeddedImage($_FILES['attachimage']['tmp_name'], 'my-attach', 'image.gif', 'base64', $_FILES['attachimage']['type']))
                     die ($mail->ErrorInfo);
                $mess .= '    :<br /><img src="cid:my-attach" border=0><br />    ,           ;-) ';
             }
    }
    $mail->Body = $mess;
    //   
    if (!$mail->Send()) die ('Mailer Error: '.$mail->ErrorInfo);
    echo '!   .         .';
}
function output_err($num)
{
    $err[0] = '!   .';
    $err[1] = '!   e-mail.';
    $err[2] = '!   .';
    echo '<p>'.$err[$num].'</p>';
    show_form();
    exit();
}
if (!empty($_POST['submit'])) complete_mail();
else show_form();
?>

Answer 1, authority 100%

class.phpmailer.php needs to be uploaded to the server and put next to the script that sends the mail message. After that, everything should work. You may need to set write permissions to the folder where the file is uploaded before sending it, AddAttachment is responsible for this.