Uzun süredir uğraştığım bir sorun bu. Formumda bir adet input file var ve ben burdan maile attachment göndermek istiyorum. Bunu nasıl yapabilirim. Denediğim hiç bir yol olmadı.
<!-- Ajax Form --> <script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ // Gönder butonuna basılınca çalıştır $("#gbuton").click(function(){ // Formdan gelen degerleri degerler değişkenine atıyoruz var degerler = $("form").serialize();
// Ajax Methodunu Başlatıyoru< $.ajax({
type: "post", // gönderme tipi url: "ajax-APP.php", // gönderdiğimiz dosyas data : degerler, // gönderilcek veriler success : function(cevap){ // eğer başarılı ise alert(cevap); // ajax.php den gelen değerleri alert et $('textarea').val(''); $('input').val(''); } }); }); }); </script>
Uzun süredir uğraştığım bir sorun bu. Formumda bir adet input file var ve ben burdan maile attachment göndermek istiyorum. Bunu nasıl yapabilirim. Denediğim hiç bir yol olmadı.
<?php
if ($_POST){
$adsoyad = htmlspecialchars(trim($_POST['adsoyad']));
$eposta = htmlspecialchars(trim($_POST['eposta']));
$telefon = htmlspecialchars(trim($_POST['telefon']));
$website = htmlspecialchars(trim($_POST['website']));
$dosyukle = $_FILES[dosyukle];
include 'class.phpmailer.php';
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->Host = 'smtp.gmail.com';
$mail->Port = 587;
$mail->SMTPSecure = 'tls';
$mail->Username = 'xxxxxxxxx@gmail.com';
$mail->Password = 'xxxxxxx';
$mail->SetFrom($mail->Username, $adsoyad);
$mail->AddAddress('xxxxxxx@gmail.com', $adsoyad);
$mail->CharSet = 'UTF-8';
$mail->Subject = ' Application From: ' . $adsoyad . ' /' ;
$mail->AddAttachment($_FILES['dosyukle'];
$e_body = "Contacting person is: <strong>$adsoyad </strong> <br> Website: <strong>$website</strong><br> Phone: <strong>$telefon <br>$konum</strong><br> " . PHP_EOL . PHP_EOL;
$e_reply = "<br>You can contact <strong> $adsoyad </strong> via email, $eposta";
$msg = wordwrap( $e_body . $e_reply, 170 );
$content = '<div style="background: #eee; padding: 10px; font-size: 14px">'.$msg.'</div>';
if($adsoyad == '') {
echo 'Lütfen isminizi Yazın;
} else if(trim($eposta) == ''){
echo 'Lütfen eposta adresinizi yazın';
} else if(trim($telefon) == ''){
echo 'lütfen tel no yazınız.';
} else{
$mail->MsgHTML($content);
}
if($mail->Send()) {
echo 'Mesajınız Ulaştı';
}
}
?>
Bunu nasıl çözebilirim.