Share an example of multi-choice File Upload for. net

Source: Internet
Author: User
File Upload, no refreshing upload, batch upload of files, and batch upload without refreshing, these words seem to be a lot of in the past, no matter what kind of upload can meet the actual needs is good, generally when uploading files, click the file browse box and select only one file. If you want to upload multiple files, you can browse them multiple times and click batch upload. This is also good, And the progress is displayed without refreshing, it's pretty good. There are also examples on the Internet that can be used to select multiple files. When you Click Browse, you can press Ctrl or shift to select multiple files and then upload them. But it seems like this. there are not many net versions. My friends sent me a demo that I have already compiled. Then I sorted it out a little bit. I think it's okay. I can share it with you. If it's good or bad, I won't say it, because there is no perfect thing, it can be applied to some of your actual needs. First, the mechanism for uploading this method is also embedded with a SWF file like a general brushless newest upload, which achieves the same effect as the JS call (test demo Article Download at the end)

(1) You can set the file filtering format in the browse and upload file box:

If (Form1.ddlfiletype. Value = " P " )
{
Size_limit =   " 0 " ; // 1 m = 1048576;
Types =   " *. Jpg; *. BMP; *. gif; " ;
Types_description =   " Image files " ;
}
Else   If (Form1.ddlfiletype. Value = " A " )
{
Size_limit =   " 0 " ;
Types =   " *. MP3; *. wmv " ;
Types_description =   " Audio files " ;
}
Else   If (Form1.ddlfiletype. Value = " R " )
{
Size_limit =   " 0 " ;
Types =   " *. Rm; *. Avi; *. MpEG; *. rmvb; *. wmv; *. dat " ;
Types_description =   " Video Files " ;
}
Else
{
Size_limit =   " 0 " ;
Types =   " *.* " ;
Types_description =   " All files " ;
}

 

(2) Click the select file button to bring up the file browsing box. Double-click the file or click the OPEN button in the lower right corner to perform related operations, the main purpose is to buffer the browsed files in the format of file streams (simple session buffering), such:

In fact, after multiple files are selected to be opened, JS implicitly executes the onclick event of a button. After the execution is complete, the files are listed in the list, for example:

The complete test is as follows (relatively simple :))

In the config configuration, you can upload up to 2 GB of files. Select three files with a slightly larger size as follows:

 

Click the Save button to upload the file to the corresponding folder and write data to the database.

After writing it, I found that when I inserted images into my blog, I could choose multiple options for inserting images and uploading images in my blog garden.

Download demo and source code:Multi-choice File Upload (. NET)

Note: When selecting a file type, you must reload the page and try to process the onchange event from the drop-down list so that it does not refresh the page, but it is not feasible, in addition, if you want to cancel the current file during the upload of a large file and ask it to upload the next file at the same time, this is not handled yet. It should be said that it is two legacy problems. To runProgramYou may need to install aspnetajax. Delete and clear the updatepanel. If you do not want to install it, delete the scriptmanager and updatepanel controls on the page, in config, comment out and release the original comment.

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.