From: http://www.cnblogs.com/dreamof/archive/2009/12/02/1615515.html
This control allows you to upload multiple files at the same time. You can set the quantity, size, and format of the files to be uploaded based on your needs.
Download the htmlinputfiles Control
1. properties of the htmlinputfiles Control
Is the main property of the control:
Attribute name Function
Filefilter
Maxcount allows you to upload a maximum of several files.
Recordcount: Set the initial value of the upload control.
Filesize: set the size of the uploaded file.
The functions of other attributes are clear at a glance and will not be introduced.
2. Use the htmlinputfiles Control
In
The "add upload" button is used to add upload attachments, and the "reduce upload" button is used to reduce upload attachments.
The specific usage is as follows:
Front-end code:
<Div>
<PC3: htmlinputfiles id = "htmlinputfiles1" runat = "server" addbuttonvisible = "true" maxcount = "15" recordcount = "1" filefilter = ". GIF |. JPG |. JPEG |. RAR |. TXT "/>
<Br/>
<Asp: button id = "btnupfile" runat = "server" onclick = "btnupfile_click" text = "Upload"/>
</Div>
Background code:
Protected void btnupfile_click (Object sender, eventargs E)
{
If (this. htmlinputfiles1.checkallpostedfile (true ))
{
For (INT I = 0; I <= This. htmlinputfiles1.recordcount; I ++)
{
System. Io. fileinfo info = new fileinfo (this. htmlinputfiles1 [I]. postedfile. filename );
String filename = info. Name;
String filepath = "uploads/" + system. guid. newguid (). tostring () + filename;
This. htmlinputfiles1 [I]. postedfile. saveas (server. mappath (filepath ));
}
}
}