2 回答
TA贡献1946条经验 获得超4个赞
因为var formData = $("#formAll").serialize();,它不能序列化IFormFile,你需要追加IFormFile到formData.
<script type="text/javascript">
$(document).ready(function () {
$("#formAll").submit(function (event) {
event.preventDefault();
var formData = new FormData();
formData.append('Member_NameFirst', $('#Member_NameFirst').val());
formData.append('Member_UploadPicture', $('#Member_UploadPicture')[0].files[0]);
$.ajax({
url: "https://localhost:44307/home/getmember",
type: 'POST',
data: formData,
dataType: 'json',
processData: false,
contentType: false,
success: function (data) {
//code
},
error: function (error) {
//code
}
});
}) })
</script>
TA贡献1802条经验 获得超10个赞
消除
@Html.EditorFor(model => model.Member_UploadPicture, new { htmlAttributes = new { @class = "form-control-file", @id = "Member_UploadPicture" } })
添加到你的ajax请求
processData: false,
contentType: false,
- 2 回答
- 0 关注
- 101 浏览
添加回答
举报