如何使用vb.asp将多个文件上传到文件夹 [英] How to upload multiple file to folder using vb.asp

查看:72
本文介绍了如何使用vb.asp将多个文件上传到文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友们,



我需要从html表上传文件:我在html表行中上传文件,然后点击保存按钮,将所有文件上传到文件夹。



我的问题是:只上传一行文件。我添加另一行没有执行。



我尝试过:



 var length = $(#tblInvoices2)。children()。length; 


var test = new FormData();
var fileUpload;
var文件;
for(var i = 0; i< length; i ++){
fileUpload = $(#tblInvoices2)。find(。files)。get(i);
files = fileUpload.files;
test.append(files [i] .name,files [i]);
}
$ .ajax({
url:FileUploadHandler.ashx,
类型:POST,
contentType:false,
processData: false,
data:test,
// dataType:json,
success:function(result){
alert(result);
},
错误:函数(xhr,错误){
alert(错误);
}
});



< b> handler:

如果context.Request.Files IsNot Nothing则
For Each file As String in context.Request.Files
Dim uploadedFile = context.Request.Files(file)
如果uploadedFile.ContentLength> 0然后
Dim appData = context.Server.MapPath(〜/ AIOCD0373 /)
Dim fileName = System.IO.Path.GetFileName(uploadedFile.FileName)
uploadedFile.SaveAs(System .IO.Path.Combine(appData,fileName))
End if
Next
End if

解决方案
( #tblInvoices2)的儿童()长度。;


var test = new FormData();
var fileUpload;
var文件;
for(var i = 0; i< length; i ++){
fileUpload =


(#tblInvoices2)。find(。files)获得(ⅰ);
files = fileUpload.files;
test.append(files [i] .name,files [i]);
}


.ajax({
url:FileUploadHandler.ashx,
类型:POST,
contentType:false,
processData:false,
data:test,
// dataType:json,
success:function(result){
alert(result);
},
错误:函数(xhr,错误){
alert(错误);
}
});



处理程序:

如果context.Request.Files IsNot Nothing则
For Each file As String in context.Request .Files
Dim uploadedFile = context.Request.Files(file)
If uploadedFile.ContentLength> 0然后
Dim appData = context.Server.MapPath(〜/ AIOCD0373 /)
Dim fileName = System.IO.Path.GetFileName(uploadedFile.FileName)
uploadedFile.SaveAs(System .IO.Path.Combine(appData,fileName))
End if
Next
End if


Dear Friends,

I need to upload files from html table: I have file upload in html table rows then click save button that all files are upload to folder.

My problem is: only one row of file only upload. I add another row didn't execute.

What I have tried:

  var length = $("#tblInvoices2").children().length;
       
 
                var test = new FormData();
                   var fileUpload;
                   var files;
                for (var i = 0; i < length; i++) {     
                    fileUpload= $("#tblInvoices2").find(".files").get(i);                
                    files= fileUpload.files;          
                    test.append(files[i].name, files[i]);
                    }
$.ajax({
                    url: "FileUploadHandler.ashx",
                    type: "POST",
                    contentType: false,
                    processData: false,
                    data: test,
                    // dataType: "json",
                    success: function (result) {
                        alert(result);
                    },
                    error: function(xhr,err){
    alert("Error");
}
                });


handler:

If context.Request.Files IsNot Nothing Then
           For Each file As String In context.Request.Files
               Dim uploadedFile = context.Request.Files(file)
               If uploadedFile.ContentLength > 0 Then
                   Dim appData = context.Server.MapPath("~/AIOCD0373/")
                   Dim fileName = System.IO.Path.GetFileName(uploadedFile.FileName)
                   uploadedFile.SaveAs(System.IO.Path.Combine(appData, fileName))
               End If
           Next
       End If

解决方案

("#tblInvoices2").children().length; var test = new FormData(); var fileUpload; var files; for (var i = 0; i < length; i++) { fileUpload=


("#tblInvoices2").find(".files").get(i); files= fileUpload.files; test.append(files[i].name, files[i]); }


.ajax({ url: "FileUploadHandler.ashx", type: "POST", contentType: false, processData: false, data: test, // dataType: "json", success: function (result) { alert(result); }, error: function(xhr,err){ alert("Error"); } });


handler:

If context.Request.Files IsNot Nothing Then
           For Each file As String In context.Request.Files
               Dim uploadedFile = context.Request.Files(file)
               If uploadedFile.ContentLength > 0 Then
                   Dim appData = context.Server.MapPath("~/AIOCD0373/")
                   Dim fileName = System.IO.Path.GetFileName(uploadedFile.FileName)
                   uploadedFile.SaveAs(System.IO.Path.Combine(appData, fileName))
               End If
           Next
       End If


这篇关于如何使用vb.asp将多个文件上传到文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆