не получается передать input type="file" через php mail

Как бы не пытался, но передача input="file" не работает

$('#web_form_22').submit(function(){
    $.post(
        '/ajax/buh-opros-send.php', // адрес обработчика
         $("#web_form_22").serialize(), // отправляемые данные

        function(msg) { // получен ответ сервера

            $('#web_form_22').css('width','100%');

             $('#alert-success-form').css('display','block');

            $('#web_form_22').hide('slow');

            $('#my_message').html(msg);
        }
    );
    return false;
});
<form id="web_form_22" enctype="multipart/form-data" class="spec-form option__item" method="POST">

<div class="input-group input-file" name="Fichier1">
      <input type="text" class="form-control input" placeholder="Выберите файл..." style="cursor: pointer;">
</div>

</form>

<?php

$comp = $_POST['COMP'];
$comp = htmlspecialchars($comp);
$comp = urldecode($comp);
$comp = trim($comp);

$fio = $_POST['NAME'];
$fio = htmlspecialchars($fio);
$fio = urldecode($fio);
$fio = trim($fio);

$tel = $_POST['PHONE'];
$tel = htmlspecialchars($tel);
$tel = urldecode($tel);
$tel = trim($tel);

$email = $_POST['EMAIL'];
$email = htmlspecialchars($email);
$email = urldecode($email);
$email = trim($email);

$coment1 = $_POST['COMENT1'];
$coment1 = htmlspecialchars($coment1);
$coment1 = urldecode($coment1);
$coment1 = trim($coment1);

$spos = $_POST['SPOS'];
$spos = htmlspecialchars($spos);
$spos = urldecode($spos);
$spos = trim($spos);

$sposzak = $_POST['SPOSZAK'];
$sposzak = htmlspecialchars($sposzak);
$sposzak = urldecode($sposzak);
$sposzak = trim($sposzak);

$ob = $_POST['OB'];
$ob = htmlspecialchars($ob);
$ob = urldecode($ob);
$ob = trim($ob);

$coment2 = $_POST['COMENT2'];
$coment2 = htmlspecialchars($coment2);
$coment2 = urldecode($coment2);
$coment2 = trim($coment2);

$schet7 = $_POST['SCHET7'];
$schet7 = htmlspecialchars($schet7);
$schet7 = urldecode($schet7);
$schet7 = trim($schet7);

$rez6 = $_POST['REZ6'];
$rez6 = htmlspecialchars($rez6);
$rez6 = urldecode($rez6);
$rez6 = trim($rez6);

$ch  = stripslashes($_POST['ch']);
$choice  = stripslashes($_POST['choice']);
if(!empty($_POST['ch'])) {
     foreach($_POST['ch'] as $check) {
        $ch .= $check;
      }
  }
  if(!empty($_POST['choice'])) {
       foreach($_POST['choice'] as $check) {
          $choice .= $check;
        }
    }

$radio1 = $_POST['RADIO1'];
$radiotreb1 = $_POST['RADIOTREB1'];

$radiotreb3 = $_POST['RADIOTREB3'];
$radiotreb3 = htmlspecialchars($radiotreb3);
$radiotreb3 = urldecode($radiotreb3);
$radiotreb3 = trim($radiotreb3);

$coment3 = $_POST['COMENT3'];
$coment3 = htmlspecialchars($coment3);
$coment3 = urldecode($coment3);
$coment3 = trim($coment3);




if(!empty($_FILES["Fichier1"]["name"])){

                // File path config
                $targetDir = "upload/";
                $fileName = basename($_FILES["Fichier1"]["name"]);
                $targetFilePath = $targetDir . $fileName;
                $fileType = pathinfo($targetFilePath,PATHINFO_EXTENSION);

                // Allow certain file formats
                $allowTypes = array('pdf', 'doc', 'docx', 'jpg', 'txt', 'png', 'jpeg');
                if(in_array($fileType, $allowTypes)){
                    // Upload file to the server
                    if(move_uploaded_file($_FILES["Fichier1"]["tmp_name"], $targetFilePath)){
                        $uploadedFile = $targetFilePath;
                    }else{
                        $uploadStatus = 0;
                        $statusMsg = "Sorry, there was an error uploading your file.";
                    }
                }else{
                    $uploadStatus = 0;
                    $statusMsg = 'Sorry, only PDF, DOC, JPG, JPEG, & PNG files are allowed to upload.';
                }
            }

$toEmail = '[email protected]';
$from = '[email protected]';
$fromName = 'Делис Архив';
$emailSubject = 'Бухгалтерский опрос archiv.ru';



  $htmlContent = '
                      <p>Название компании: '.$comp.'</p>
                      <p>ФИО: '.$fio.'</p>
                      <p>E-mail: '.$email.'</p>
                      <p>Телефон: '.$tel.'</p>
                      <p>Комментарии к полям выше: '.$coment1.'</p>

                      <p>Способ передачи документов для распознавания: '.$spos.'</p>
                      <p>Способ передачи результата заказчику : '.$sposzak.'</p>
                      <p>Предварительный объём планируемой передачи документов/образов: '.$ob.'</p>
                      <p>Комментарии к полям выше: '.$coment2.'</p>

                      <p>Документы для распознавания: '.$ch.'</p>
                      <p>Документы для распознавания (если выбрал другое): '.$schet7.'</p>
                      <p>Желаемый результат распознавания: '.$choice.'</p>
                      <p>Желаемый результат распознавания (если выбрал другое): '.$rez6.'</p>
                      <p>Формирование .pdf файлов: '.$radio1.'</p>
                      <p>Требования к проверке правильности оформления электронных документов: '.$radiotreb1.'</p>
                      <p>Требования к проверке правильности оформления электронных документов (что требуется): '.$radiotreb3.'</p>
                      <p>Комментарии к полям выше: '.$coment3.'</p>
                  ';

$headers = "From: $fromName"." <".$from.">";



$semi_rand = md5(time());
                    $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";

                    // Headers for attachment
                    $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\"";

                    // Multipart boundary
                    $message = "--{$mime_boundary}\n" . "Content-Type: text/html; charset=\"UTF-8\"\n" .
                    "Content-Transfer-Encoding: 7bit\n\n" . $htmlContent . "\n\n";

                    // Preparing attachment
                    if(is_file($uploadedFile)){
                        $message .= "--{$mime_boundary}\n";
                        $fp =    @fopen($uploadedFile,"rb");
                        $data =  @fread($fp,filesize($uploadedFile));
                        @fclose($fp);
                        $data = chunk_split(base64_encode($data));
                        $message .= "Content-Type: application/octet-stream; name=\"".basename($uploadedFile)."\"\n" .
                        "Content-Description: ".basename($uploadedFile)."\n" .
                        "Content-Disposition: attachment;\n" . " filename=\"".basename($uploadedFile)."\"; size=".filesize($uploadedFile).";\n" .
                        "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n";


                    $message .= "--{$mime_boundary}--";
                    $returnpath = "-f" . $email;

                    // Send email
                  $mail =  mail($toEmail, $emailSubject, $message, $headers, $returnpath);

                    // Delete attachment file from the server
                    @unlink($uploadedFile);
                }
                else{
                     // Set content-type header for sending HTML email
                    $headers .= "\r\n". "MIME-Version: 1.0";
                    $headers .= "\r\n". "Content-type:text/html;charset=UTF-8";

                    // Send email
                    $mail = mail($toEmail, $emailSubject, $htmlContent, $headers);
                }



?>

Материал брал по данной ссылке https://www.codexworld.com/php-contact-form-send-email-with-attachment-on-submit/, но не могу разобраться, почему письмо приходит без файла


Ответы (0 шт):