Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/316.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在asp.net c#中使用文本框val上传文件ajax_C#_Jquery_Asp.net_Ajax_Webforms - Fatal编程技术网

在asp.net c#中使用文本框val上传文件ajax

在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="

我想将上传的文件发送到web方法并保存它,然后将文本框值保存到数据库中。但我对此一无所知,请帮助我谢谢大家。
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;
    }

问题太广泛了。像“我不知道怎么做”这样的问题没有得到回答。而且,所有这些问题以前都得到了回答。做一些搜索。