Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/421.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
Javascript 从多个文件夹上载多个文件<;输入类型=';文件'&燃气轮机;以同步方式动态创建的控件(不是一个具有多个控件的控件)_Javascript_Jquery_Asp.net_Ajax_Upload - Fatal编程技术网

Javascript 从多个文件夹上载多个文件<;输入类型=';文件'&燃气轮机;以同步方式动态创建的控件(不是一个具有多个控件的控件)

Javascript 从多个文件夹上载多个文件<;输入类型=';文件'&燃气轮机;以同步方式动态创建的控件(不是一个具有多个控件的控件),javascript,jquery,asp.net,ajax,upload,Javascript,Jquery,Asp.net,Ajax,Upload,ASP.NET 4.8(vb.NET) 我编写了一段代码,从服务器上动态构建的不同输入文件控件上载多个文件。 因为最多可以上传17个文件,所以需要同步上传,所以我使用了Ajax。 每个文件都有一个具有唯一Id的特定名称 当我们使用以下代码时,用于查找工作的代码: windows 2008服务器r2 IIS 7 .NET 4.5 (偶尔会出现“超时”错误,但大多数情况下它工作正常,在旧服务器上运行时仍然工作) 现在系统升级到 windows 2019服务器 IIS 10 .NET 4.8

ASP.NET 4.8(vb.NET) 我编写了一段代码,从服务器上动态构建的不同输入文件控件上载多个文件。 因为最多可以上传17个文件,所以需要同步上传,所以我使用了Ajax。 每个文件都有一个具有唯一Id的特定名称

当我们使用以下代码时,用于查找工作的代码:

  • windows 2008服务器r2
  • IIS 7
  • .NET 4.5 (偶尔会出现“超时”错误,但大多数情况下它工作正常,在旧服务器上运行时仍然工作)
现在系统升级到

  • windows 2019服务器
  • IIS 10
  • .NET 4.8
现在,当尝试上载2个或更多文件时,尤其是当它们是大文件(每个文件的限制为5MB)时,需要花费很长时间(可能需要几分钟),并且至少一些上载会因“超时”错误而失败

这是什么原因造成的? 有更好的方法吗

这是JavaScript代码:

$(document).ready(function ()
        {  
            
            $('#btnUploadFile').on('click', function ()
            {
               upload_errors = 0;
           
               disable_upload_btn();                           


                //var xhr = new XMLHttpRequest();
                var data = new FormData();
                var status = 1;                
                var filesnum = 0;

                $("#frmfree").find("input[type=file]").each(function (index, field) 
                {
                   
                    var xhr = new XMLHttpRequest();
                    var data = new FormData();

                    var file = field.files[0];
                    

                    if (file != null)
                    {                
                        filesnum++;
                    
                        var sug_mismach = ($(this).attr('class'));                       

                        var field_ids = this.id.split("_");
                                                   
                        if (file.size ==0)
                        {
                            errorMessage =  ' empty file ' ;
                            alert(errorMessage);
                            $('#fu_' + field_ids[1] + "_" + field_ids[2]).val("");
                            
                            if (sug_mismach != '99') {$('#uploaded_sug' + field_ids[1] + "_" + field_ids[2]).val(""); alert($('#uploaded_sug' + field_ids[1] + "_" + field_ids[2]).val());}
                            return;
                        }

                        if (file.size > 5242880 || file.fileSize > 5242880) {
                            upload_errors += 1;  
                            errorMessage =  ' too big ';
                            alert(errorMessage);                                                     
                            enable_upload_btn();
                            return ;
                        }
                       
                        //These extra fields are the for the final file name 
                        data.append(file.name, file);
                        data.append('shana', $('#shana').val());
                        data.append('pnimi', $('#pnimi').val());
                        data.append('idno', $('#idno').val());
                        data.append('sug_bakasha', $('#sug_bakasha').val());

                                              
                        var ajaxRequest = $.ajax(
                            {
                            type: "POST",                        
                            url: "Siyua_Upload.aspx?id=" + this.id,
                            contentType: false,
                            processData: false,                            
                            data: data,                          
                            success: function (response) 
                            {                               
                                var array = response.split("^");
                               
                                if (array[0] != '' && array[0] != null) 
                                {
                               
                                    $('#diverr' + field_ids[1] + "_" + field_ids[2]).css({ 'color': 'red' });
                                    $('#diverr' + field_ids[1] + "_" + field_ids[2]).text('upload failed: ' + array[0]);
                                    upload_errors += 1;
                                    status = "0"; //failed
                                }
                                else if (array[1] != '' && array[1] != null) 
                                {                                   
                                    //$('#tdLink' + field_ids[1] + "_" + field_ids[2]).text(array[1]);
                                    
                                    //alert($('#tdLink' + field_ids[1] + "_" + field_ids[2]).html);
                                    $('#tdLink' + field_ids[1] + "_" + field_ids[2]).html(array[1]);
                                    $('#fu_' + field_ids[1] + "_" + field_ids[2]).val("");
                                    //$('#txt_' + field_ids[1] + "_" + field_ids[2]).val("");
                                    $('#uploaded_sug' + field_ids[1] + "_" + field_ids[2]).val(sug_mismach);
                                    $('#diverr' + field_ids[1] + "_" + field_ids[2]).css({ 'color': 'green'});
                                    $('#diverr' + field_ids[1] + "_" + field_ids[2]).text('upload successful');                                                                
                                    status = "1";
                                }
                                
                                //alert("success: " + response);
                                
                            },
                            error: function (xhr, err) 
                            {
                                alert("readyState: " + xhr.readyState + "\nstatus: " + xhr.status + "\nerror: " + xhr.responseText + "\nresponseText: " + xhr.statusText  );                                
                                $('#diverr' + field_ids[1] + "_" + field_ids[2]).css({ 'color': 'red' });
                                $('#diverr' + field_ids[1] + "_" + field_ids[2]).text('upload failed: ' + xhr.responseText);
                                status = "0";
                                upload_errors += 1;
                            }
                        });
                                                                  
                    }       
                if (filesnum==0)
                {
                    alert ("no files were selected");                    
                    enable_upload_btn();
                }                
           
            });
            return false;
        });
    

  $(document).ajaxStop(function () 
        {
            //alert('all files were uploaded');       
           enable_upload_btn();           
            //alert(upload_errors);
            if (upload_errors == 0)  {
                 
                obj = document.forms[0];                        
                $("#frmfree").submit();
            }
                
        });

'''