[英]upload multiple files from one input in user control
I am working on a 4.0 WebForms application that allows users to upload files while submitting a ticket. 我正在使用4.0 WebForms应用程序,该应用程序允许用户在提交票证的同时上传文件。 I've created a user control that has the input field: 我创建了一个具有输入字段的用户控件:
<input type="file" multiple="multiple" id="files" runat="server" onchange="changeFunc()" />
to select files. 选择文件。 The input field is inside of an UpdatePanel
and the onchange
uses javascript to click an asp button so that I can start the upload process automatically. 输入字段位于UpdatePanel
内部, onchange
使用javascript单击asp按钮,以便我可以自动开始上传过程。
In the click event for the button I've tried using the following code to collect all the files from the input field: 在按钮的click事件中,我尝试使用以下代码从输入字段中收集所有文件:
List<string> fileNames = new List<string>();
for (int i = 0; i < Request.Files.Count; i++)
{
HttpPostedFile file = Request.Files[i];
fileNames.Add(file.FileName);
}
Unfortunately, Files.Count
is always zero not matter how many files I have selected. 不幸的是,无论我选择了多少个文件, Files.Count
始终为零。 I seem to be missing something basic here and I'm not sure what that is. 我似乎在这里缺少基本的东西,我不确定那是什么。
我是一个虚拟人,并且触发器下的按钮为asp:AsyncPostBackTrigger
而不是asp:PostBackTrigger
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.