Answer the question
In order to leave comments, you need to log in
How to send a file attached to a form via phpmailer?
The whole question is in the title.
How to attach a file to a message using phpmailer?
All data entered by the client is sent $text = $_POST['message'];
How to add a file to $text?
Data is collected from the form (I don’t know how to collect file):
function order_form(){
var message = '';
var client_name = $("#client_name_order").val();
var client_phone = $("#client_phone_order").val();
var client_email = $("#client_email_order").val();
var client_text = $("#client_text_order").val();
if (client_phone == ''){
//alert('Пожалуйста, напишите свой номер телефона.');
swal({ title: "", text: "Не заполнено поле 'Ваш телефон'", type: "error", confirmButtonText: "ОK", confirmButtonColor: "#CD0117" });
return;
}else if(client_email == ''){
swal({ title: "", text: "Не заполнено поле 'Ваш e-mail'", type: "error", confirmButtonText: "ОK", confirmButtonColor: "#CD0117" });
return;
}else{
message = 'Телефон: ' + client_phone + '<br /> Имя: ' + client_name + '<br /> Почта: ' + client_email + '<br /> Сообщение: ' + client_text;
$.ajax({
url: '/mailer/send_letter.php',
type: 'post',
data: 'mode=call_back&message=' + message,
dataType: 'text',
success: function(data) {
if (data = '0'){
swal({ title: "", text: "Ваша заявка успешно отправлена!", type: "success", confirmButtonText: "ОK", confirmButtonColor: "#CD0117" });
setTimeout(function(){ location.reload(); }, 3000);
return;
}else{
swal({ title: "", text: "Ошибка отправки сообщения", type: "error", confirmButtonText: "ОK", confirmButtonColor: "#CD0117" });
return;
}
}
});
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question