简体   繁体   中英

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. 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.

In the click event for the button I've tried using the following code to collect all the files from the input field:

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. I seem to be missing something basic here and I'm not sure what that is.

我是一个虚拟人,并且触发器下的按钮为asp:AsyncPostBackTrigger而不是asp:PostBackTrigger

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM