我想发送电子邮件的附件。我想从jquery ajax中做到这一点,但我尝试使用jquery ajax来处理文件类型。我不成功。如果有人如何使用这个帮助我解决这个问题。
<?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);
}
});
}
谢谢...