在asp.net c#中使用文本框val上传文件ajax
我想将上传的文件发送到web方法并保存它,然后将文本框值保存到数据库中。但我对此一无所知,请帮助我谢谢大家。在asp.net c#中使用文本框val上传文件ajax,c#,jquery,asp.net,ajax,webforms,C#,Jquery,Asp.net,Ajax,Webforms,我想将上传的文件发送到web方法并保存它,然后将文本框值保存到数据库中。但我对此一无所知,请帮助我谢谢大家。 HTML: <input type="file" name="fuUpload" id="fuUpload" multiple="multiple" /> <input name="txtName" type="text" id="
HTML:
<input type="file" name="fuUpload" id="fuUpload" multiple="multiple" />
<input name="txtName" type="text" id="post-description" />
<input type="submit" name="btnSave" value="Save" id="btnSave" />
var postDesc = $("#btnSave").val();
var img = $("#file-input")[0].files[0].name;
$.ajax({
url: "Default.aspx/IsLeapYear",
contentType: "application/json; charset=utf-8",
data: '{imgbase: "' + img + '",}',
type: "POST",
success: function (response) {
toastr.success('Post updated');
retrieveData();
$("#post-import").modal('hide');
},
error: function (rep) {
toastr.error('Update failed, try again');
}
});
[System.Web.Services.WebMethod]
public static bool IsLeapYear(??? ?????)
{
return true;
}
WEB方法:
<input type="file" name="fuUpload" id="fuUpload" multiple="multiple" />
<input name="txtName" type="text" id="post-description" />
<input type="submit" name="btnSave" value="Save" id="btnSave" />
var postDesc = $("#btnSave").val();
var img = $("#file-input")[0].files[0].name;
$.ajax({
url: "Default.aspx/IsLeapYear",
contentType: "application/json; charset=utf-8",
data: '{imgbase: "' + img + '",}',
type: "POST",
success: function (response) {
toastr.success('Post updated');
retrieveData();
$("#post-import").modal('hide');
},
error: function (rep) {
toastr.error('Update failed, try again');
}
});
[System.Web.Services.WebMethod]
public static bool IsLeapYear(??? ?????)
{
return true;
}
问题太广泛了。像“我不知道怎么做”这样的问题没有得到回答。而且,所有这些问题以前都得到了回答。做一些搜索。