下面是对服务器上静态 Web 方法的 Ajax 请求。我想将文件及其相关详细信息发送到服务器。即使我将数据发送到服务器,我也无法使用 c#.net 在服务器端访问文件。
最困难的部分是在静态 WebMethod 中访问 FileUpload 控件。
$.ajax({
type: 'POST',
contentType: "application/json; charset=utf-8",
url: 'UserProfile.aspx/EditProfile',
data: "{'file':'" + document.getElementById('FileUpload1').files[0] + "'}",
async: true,
success: function (response) {
$('#dialog-form').dialog("close");
}
});