Jquery 将多部分表单过帐到其自身无法获取文件名

Jquery 将多部分表单过帐到其自身无法获取文件名,jquery,forms,post,file-upload,Jquery,Forms,Post,File Upload,我发布了一个带有jquery的表单,其中有一个文件上传。我无法获取文件名,我一直获取userfile未设置。。。尝试捕获文件名时 $(document).ready(function(){ $("#chmail").validate({ debug: false, submitHandler: function(form) { $.post('new_mail.php', $("#chmail").serialize(), function(data) { $('#mainBody').html

我发布了一个带有jquery的表单,其中有一个文件上传。我无法获取文件名,我一直获取userfile未设置。。。尝试捕获文件名时

$(document).ready(function(){
$("#chmail").validate({
debug: false,
submitHandler: function(form) {
$.post('new_mail.php', $("#chmail").serialize(), function(data) {
$('#mainBody').html(data);
$("#mainBody").find("script").each(function(i) {
eval($(this).text());
});
});
}
});
});

if (isset($_FILES["userfile"]["name"])) {
echo $_FILES["userfile"]["name"];
}


<form method="post" action="" id="chmail" name="chmail" enctype="multipart/form-data">
<input type="file" id="userfile" name="userfile" />
<button type="submit" value="Send">
</form>
如有任何帮助,将不胜感激: 非常感谢这很好用

在您的页面上设置iframe。在表单中,将目标设置为iframe,并将操作设置为调用上载文件的脚本。不需要其他脚本

<iframe name="my-iframe" frameborder="0" scrolling="no"></iframe>


<form method="post" id="chmail" name="chmail" enctype="multipart/form-data" action="process_mail.php" target="my-iframe">

无法通过Ajax调用上载文件。阅读更多[此处][1]。[1] :找到一个非常有效的答案抱歉,不知道如何将代码放入注释IFrame设置表单setup