1

I want to send attachment of email. I want to do it from jquery ajax but I tried with jquery ajax to file type. I am not successful. If anyone how use this help me to solve this.

<?php
 <form action="../PHP/sendemail.php" enctype="multipart/form-data" method="post" id="upload" name="upload">
<table>
<tbody>
 <td style="width: 190px;padding-right: 0px ">
   <input type="file" name="uploaded_file" id="uploaded_file" class="text-center center-block well well-sm"><br>
 </td>
 <td>
    <input type="submit" class="btn btn-info btn-sm" value="Apply Now" id="btn<?= $row['vacancyid']?>" name="btn<?= $row['vacancyid']?>">
 </td>
</tbody>
</table>
?>
<script>
$('#upload').click(function(event){

    var FormData = new FormData($(form)[1]);

    $.ajax({
        url : "sendmail.php",
        data : {FormData:uploaded_file},
        type : 'POST',
        processData: false,
        contentType: false,
        success : function(data){
        alert(data); 
        }
    });
  }

Thank you...

Mahendra Gunawardena
  • 1,956
  • 5
  • 26
  • 45

0 Answers0