C #. NET + JS file batch upload solution attachment download

Source: Internet
Author: User

 

All right, you just need to download this attachment and modify it to the desired effect. Note that you must run it in IIS. Otherwise, an error will be reported for the upload path! Finished)

If you need to upload a larger file, I will tell you how to set it.) because the recent project requires multiple files to be uploaded at the same time, I found a method on the Internet. Swfupload: So I upload and share multiple files in my C #. NET environment to everyone at the same time! This instance can only upload up to 500 mb of data.

Fully supports IE and Firefox!

Some applications are very unfriendly. Generally, files can only be uploaded one by one in Web mode. Customers all want to select a lot of files once, and then let the system upload all the selected files.

We will propose a perfect solution to this problem. There are two main technologies used: Flash and smartupload flash allow the customer to select multiple files at a time, and smartupload is responsible for uploading the selected files to the server.

It's actually the swfupload method. Some friends can see it here. For more information, visit the swfupload Official Website: http://www.swfupload.org/

Batch upload. Let me first look at the client interface. Select multiple files. Upload progress display)

 

In fact, it is very convenient to achieve the effect in the figure. After reading the description below, I believe everyone wants to see the effect. Download the attachment at the bottom.

The following describes some basic methods to use.

The first is the default. aspx File Upload instance. It is relatively simple and generally does not need to be changed! Below are some parameter settings

To set the file upload size, you only need to modify the maxrequestlength in the web. config file to be 512000 = 1024*500, so you can set the size you want to set!

C # code

</SPA n> httpruntim executiontimeout </SPA n> = </SPA n> "</SPA n> 300 </SPA n>" </SPA n> maxrequestlength </SPA n>/ spa n >=</SPA n> "</SPA n> 512000 </SPA n>" </SPA n> usefullyqualifiedredirecturl </SPA n> = </SPA n>" </SPA n> false </SPA n> "</SPA n>/> </SPA n>

 
 

File directory selection settings

Find the upload. aspx background code upload. aspx. CS in the root directory.

C # code

</SPA n> string </SPA n> filenam </SPA n> = </SPA n> httpfile. filename; </SPA n> string </SPA n> prestr </SPA n >=</SPA n> </SPA n> "" </SPA n>; prestr </SPA n >=</SPA n> system. datetime. now. tostr </SPA n> + </SPA n> "</SPA n >_</SPA n>" </SPA n>; prestr </SPA
N >=</SPA n> prestr. replac </SPA n> "</SPA n>-</SPA n>" </SPA n>,

C # code
</SPA n> string </SPA n> filenam </SPA n> = </SPA n> httpfile. filename; </SPA n> string </SPA n> prestr </SPA n >=</SPA n> </SPA n> "" </SPA n>; prestr </SPA n >=</SPA n> system. datetime. now. tostr </SPA n> + </SPA n> "</SPA n >_</SPA n>" </SPA n>; prestr </SPA
N >=</SPA n> prestr. replac </SPA n> "</SPA n>-</SPA n>" </SPA n>. </SPA n> "" </SPA n>; prestr </SPA n >=</SPA n> prestr. replac </SPA n> "</SPA n>: </SPA n>" </SPA n>, </SPA n> "" </SPA n>; prestr </SPA n >=</SPA n> prestr. replac </SPA n> "</SPA n>" </SPA n>,
</SPA n> "" </SPA n>; </SPA n> // </SPA n> prestr to change the name of the uploaded file </SPA n> string </SPA n> uploadpath </SPA n >=</SPA n> server. mappath </SPA n> "</SPA n> Temp \ </SPA n>" </SPA n> + </SPA n> prestr </SPA n>/ spa n> + </SPA n> filename; </SPA n> // </SPA n> relative directory
, There is a temp folder </SPA n> httpfile. savea uploadpath; </SPA n> // </SPA n> store uploaded files </SPA n> session [</SPA n> "</SPA n> filelist </SPA n> "</SPA n>] </SPA n> + = </SPA n> uploadpath </SPA n> + </SPA n> </SPA n> "</SPA n >|</SPA n>" </SPA n>; </SPA n> // </SPA n> This method is used to obtain the actual address of the file and record it. You can call this method
Session, </SPA n> response. writ </SPA n> "</SPA n> file: </SPA n> "</SPA n> + </SPA n> uploadpath </SPA n> + </SPA n>" </SPA n> upload successful! </SPA n> "</SPA n>; </SPA n> // </SPA n> returns the victory and displays the result. </SPA n>

 
   

 

Related Article

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.