Click here to Skip to main content
13,348,874 members (78,925 online)
Click here to Skip to main content
Add your own
alternative version


26 bookmarked
Posted 23 Sep 2009

Multiple File Upload Custom Control in ASP.NET

, 23 Sep 2009
Rate this:
Please Sign up or sign in to vote.
There is already a control available in .NET for single upload. There are cases where we actually have requirement of multiple and bulk select upload of files in application so as to achieve this functionality I came up with the solution that will help developer a lot..


We have a scenario where we want to have multiple file upload with one click selection criteria. After a long search in Google, I landed up on The Code Project with the desired solution.The solution I got was not straight forward and it took me tooth and nail to fit the solution in my architecture. So I made some changes to the code that helped me to achieve the multiple upload functionality with the expected output.

Using the Code

The steps that need to be followed so as to make this work for you, are as follows:

  1. Copy Upload.cs and Upload2.cs in your app_code.
  2. Reference flash.dll in your website. This will appear in bin folder.
  3. In the page load of your code behind, copy this code:
    protected void Page_Load(object sender, EventArgs e)
            // allows the JavaScript function to do a postback 
            // and call the onClick method 
            // associated with the linkButton LinkButton1. 
            string jscript = "function UploadComplete()
    	{" + ClientScript.GetPostBackEventReference(LinkButton1, "") + "};";       
    			"FileCompleteUpload", jscript, true); 
  4. Add this tag at the top of the ASPX page where you want your control to display:
    &lt %@ Register Assembly="FlashUpload" Namespace="FlashUpload" 
    	TagPrefix="FlashUpload" %&gt 
  5. Add the below ASPX custom tags inside form tags as follows:
    < FlashUpload:FlashUpload ID="flashUpload" runat="server" UploadPage="Upload2.axd"
    	OnUploadComplete="UploadComplete()" FileTypeDescription="All Files" 
    *.png; *.jpg; *.jpeg"
    	UploadFileSizeLimit="1800000" TotalUploadSizeLimit="2097152" />
     	< asp:LinkButton ID="LinkButton1" runat="server" 
    	OnClick="LinkButton1_Click" > </ asp:LinkButton >
  6. Add the below given tags under system.web in web.config file:
    	<remove verb="*" path="*.asmx"/>
    	<add verb="*" path="*.asmx" validate="false" 
    	System.Web.Extensions, Version=1.0.61025.0, 
    	Culture=neutral, PublicKeyToken=null"/>
    	<add verb="*" path="*_AppService.axd" validate="false" 
    	System.Web.Extensions, Version=1.0.61025.0, 
    	Culture=neutral, PublicKeyToken=null"/>
    	<add verb="GET,HEAD" path="ScriptResource.axd" 
    	type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, 
    	Version=1.0.61025.0, Culture=neutral, 
    	PublicKeyToken=null" validate="false"/>
    	< remove verb="POST,GET" path="Upload.axd"/>
    	< add verb="POST,GET" path="Upload.axd" type="Upload"/>
    	< remove verb="POST,GET" path="Upload2.axd"/>
    	< add verb="POST,GET" path="Upload2.axd" type="Upload"/>

Specify types of files you require need to be uploaded to web server folder. So we are all set and done. Build your application and run the machine.


The above approach may have some implication on security that may require to give access rights to the folder in webserver where your files are going to be saved. Remember this if in production this functionality goes for a toss.


The reference article that helped me to achieve this milestone was "Multiple File Upload With Progress Bar Using Flash and ASP.NET". Thanks to the author darick_c.


  • 23rd September, 2009: Initial post


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

santosh poojari
Technical Lead
Australia Australia
Whatsup-->Exploring--> MVC/HTML5/Javascript & Virtualization.......!

You may also be interested in...


Comments and Discussions

Questionon upload file not found - 404 Pin
jorgesomers10-Oct-15 10:12
memberjorgesomers10-Oct-15 10:12 
QuestionError in loading page Pin
Morteza Karimi24-Apr-13 3:09
memberMorteza Karimi24-Apr-13 3:09 
QuestionDo you have a version for Production server deployment Pin
AmarjeetSinghMatharu11-Dec-12 2:53
memberAmarjeetSinghMatharu11-Dec-12 2:53 
QuestionHttp I/O error Pin
Member 393135026-Mar-12 21:20
memberMember 393135026-Mar-12 21:20 
QuestionError: I/O Error: Error #2038 and HTTP Error: status code 302 Pin
Sardorious10-Feb-12 23:35
memberSardorious10-Feb-12 23:35 
AnswerRe: Error: I/O Error: Error #2038 and HTTP Error: status code 302 Pin
elmonalgotas23-Apr-12 21:30
memberelmonalgotas23-Apr-12 21:30 
Generalwidth / height? Pin
res_web13-Jul-11 6:51
memberres_web13-Jul-11 6:51 
Generalerror Pin
RuXiaoMai21-Apr-11 6:40
memberRuXiaoMai21-Apr-11 6:40 
GeneralRe: error Pin
res_web13-Jul-11 6:47
memberres_web13-Jul-11 6:47 
you need to put the Upload.cs class file in the App_Code directory of your web app
Generalreally good article Pin
Member 37653578-Jul-10 11:27
memberMember 37653578-Jul-10 11:27 
GeneralRe: really good article Pin
santosh poojari13-Jul-10 4:37
membersantosh poojari13-Jul-10 4:37 
Generalhi Pin
Ne7ven10-Jan-10 18:16
memberNe7ven10-Jan-10 18:16 
GeneralHi Santhosh, I really appreciate for making it available to all. Pin
srirammanoj7-Oct-09 13:59
membersrirammanoj7-Oct-09 13:59 
GeneralIt's seems like a 'How to' with fixes Pin
musacj25-Sep-09 2:08
membermusacj25-Sep-09 2:08 
GeneralMy vote of 2 Pin
Member 415315723-Sep-09 23:54
memberMember 415315723-Sep-09 23:54 
GeneralMy vote of 1 Pin
N3G4T1V323-Sep-09 8:16
memberN3G4T1V323-Sep-09 8:16 
GeneralRe: My vote of 1 Pin
santosh poojari23-Sep-09 10:46
membersantosh poojari23-Sep-09 10:46 
GeneralMy vote of 1 Pin
Seishin#23-Sep-09 3:12
memberSeishin#23-Sep-09 3:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.180111.1 | Last Updated 23 Sep 2009
Article Copyright 2009 by santosh poojari
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid