You need to use FormData
to send files in request with processData
and contentType
set to false
(您需要使用FormData
在processData
和contentType
设置为false
请求中发送文件)
var formData = new FormData();
formData.append("name", name);
formData.append("type", type);
formData.append("description", description);
formData.append("category", category);
formData.append("file", file.files[0]);
formData.append("acronym", acronym);
$.ajax({
url: "/Admin/SaveNewProduct",
type: "POST",
data: formData,
processData: false,
contentType: false,
success: function (response) {
alert("saved okay");
}
});
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…