一般来说 FormPost File,Form要求加上 enctype="multipart/form-data"
如果失败,那就到后台使用Request.Form处理
$("#registerMember").click(function () {
$.ajax({
url: $("#registrationForm").attr("action"),
type: "POST",
enctype: 'multipart/form-data',
contentType: "application/x-www-form-urlencoded",
data: $("#registrationForm").serialize(),
success: function (data) { //$("#spinnerDiv img").hide();
//$("#contentDiv input").removeAttr('disabled');
}
});
});
$.ajax({
url: $("#registrationForm").attr("action"),
type: "POST",
enctype: 'multipart/form-data',
contentType: "application/x-www-form-urlencoded",
data: $("#registrationForm").serialize(),
success: function (data) { //$("#spinnerDiv img").hide();
//$("#contentDiv input").removeAttr('disabled');
}
});
});
本文介绍如何在HTML表单中使用FormPostFile进行文件上传,并设置正确的enctype属性为multipart/form-data。同时展示了使用AJAX进行异步文件上传的具体实现代码,包括设置请求类型为POST以及使用serialize方法来序列化表单数据。
3万+

被折叠的 条评论
为什么被折叠?



