[Recommended]. Net batch upload control-htmlinputfiles

Source: Internet
Author: User

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 ));

}

}

}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.