Помогите настроить отправку файлов с формы
Помогите настроить отправку фото с формы
<form id="ajax_form" method="post" action="" enctype="multipart/form-data">
<div class="row">
<div class="col-6">
<label class="fieldlabels">Фото/скан паспорта с фотографией:</label>
<input type="file" name="foto_pasport" accept="image/*" />
</div>
<div class="col-6">
<label class="fieldlabels">Фото/скан паспорта с пропиской:</label>
<input type="file" name="foto_pasport2" accept="image/*" />
</div>
</div>
<div class="row">
<div class="col-12">
<label class="fieldlabels">Фото/скан банковской карты:</label>
<input type="file" name="foto_pasport" accept="image/*" />
</div>
</div>
<input type="button" name="next" class="next action-button button analyze-btn" id="sendMail"
value="Отправить заявку" />
</form>
Это часть кода.Все остальные поля текстовые приходят правильно Вот пример того как я пытался реализовать но данные не приходят не знаю в чем ошибка
$boundary = md5(date('r', time()));
$filesize = '';
$headers = "MIME-Version: 1.0\r\n";
$headers .= "From: " . $from . "\r\n";
$headers .= "Reply-To: " . $from . "\r\n";
$headers .= "Content-Type: multipart/mixed; boundary=\"$boundary\"\r\n";
$message="
Content-Type: multipart/mixed; boundary=\"$boundary\"
--$boundary
Content-Type: text/plain; charset=\"utf-8\"
Content-Transfer-Encoding: 7bit
$message";
if(is_uploaded_file($_FILES['foto_pasport']['tmp_name'])) {
$attachment = chunk_split(base64_encode(file_get_contents($_FILES['foto_pasport']['tmp_name'])));
$filename = $_FILES['foto_pasport']['name'];
$filetype = $_FILES['foto_pasport']['type'];
$filesize = $_FILES['foto_pasport']['size'];
$message.="
--$boundary
Content-Type: \"$filetype\"; name=\"$filename\"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=\"$filename\"
$attachment";
}
$message.="
--$boundary--";