You are on page 1of 5

6/20/13

Multiple file upload with asp.net 4.5 and Visual Studio 2012

DotNetJalps
HOME ABOUT ME

Search

Search

Follow me

My experiments with Microsoft.NET Technologies.

SUBSCRIBE TO MY BLOG

ARCHIVE

VISUAL STUDIO 2012

VISUAL STUDIO EXTENSIONS

DISCLAIMER

About Me

Multiple file upload with asp.net 4.5 and Visual Studio 2012
Posted on Monday, July 02, 2012 by jalpesh vadgama

This post will be part of Visual Studio 2012 feature


JALP ES H VADGAMA Development Manager @ Elan Emerging Technologies, Ahmedabad | Microsoft MVP(Visual C#) | Blogger | Writer. Having 9 years of experience in NET Technologies. V IE W MY COMP LE TE P ROFILE

series. In earlier version of ASP.NET there is no way to upload multiple files at same time. We need to use third party control or we need to create custom control for that. But with asp.net 4.5 now its possible to upload multiple file with file upload control. With ASP.NET 4.5 version Microsoft has enhanced file upload control to support HTML5 multiple attribute. There is a property called AllowedMultiple to support that attribute and with that you can easily upload the file. So what we are waiting for!! Its time to create one example. On the default.aspx file I have written following.

Follow @jalpesh

Subscribe via Email


? 1 < a s p : F i l e U p l o a dI D = " m u l t i p l e F i l e "r u n a t = " s e r v e r " Enter email address here... 2 < a s p : B u t t o nI D = " u p l o a d F i l e "r u n a t = " s e r v e r "T e x t

Submit

Subscribe in a reader

Here you can see that I have given file upload control id as multipleFile and I have set AllowMultiple file to
1/5

www.dotnetjalps.com/2012/07/Multiple-file-upload-with-asp-net-4-5-and-Visual-Studio-2012.html

6/20/13

Multiple file upload with asp.net 4.5 and Visual Studio 2012

true. I have also taken one button for uploading file.For this example I am going to upload file in images folder. Blog Archive
2013 (50) 2012 (61) December 2012 (7) October 2012 (1) September 2012 (4) August 2012 (3) July 2012 (9) Multiple file upload with asp.net mvc and HTML5 Here in the above code you can see that I have Why we should write blogs and do community work Model binding with ASP.NET 4.5 and Visual Studio 2... Free Visual Studio 2012 eBook from Telerik Dividing web.config into multiple files in asp.net... Event handler generation in Visual Studio 2012 1 2 3 4 5 6 7 8 9 1 0 1 1

As you can see I have also attached event handler for buttons click event. So its time to write server side code for this. Following code is for the server side.

? p r o t e c t e dv o i du p l o a d F i l e _ C l i c k ( o b j e c ts e n d e r ,E v e n t A r g se ) { i f( m u l t i p l e F i l e . H a s F i l e s ) { f o r e a c h ( H t t p P o s t e d F i l eu p l o a d e d F i l e { u p l o a d e d F i l e . S a v e A s ( S y s t e m . I O . P a t h . C o m b i n e ( S e r v e r R e s p o n s e . W r i t e ( " F i l eu p l o a d e ds u c c e s s f u l l y " } } }

checked whether multiple file upload control has multiple files or not and then I have save that in Images folder of web application. Once you run the application in browser it will look like following.

I have selected two files. Once I have selected and clicked on upload file button it will give message like

Multiple file upload following.


www.dotnetjalps.com/2012/07/Multiple-file-upload-with-asp-net-4-5-and-Visual-Studio-2012.html 2/5

6/20/13

Multiple file upload with asp.net 4.5 and Visual Studio 2012

with asp.net 4.5 and Visual S... Third year in a row- Microsoft MVP again!! Quick tour of visual studio 2012 features so far June 2012 (4) May 2012 (10) April 2012 (13) March 2012 (1) February 2012 (2) January 2012 (7) 2011 (95) 2010 (74) 2009 (49) 2008 (25) 2007 (194) 2006 (35)

As you can see now it has successfully upload file and you can see in windows explorer like following.

Temukan kami di Facebook

DotNetJalps
Suka 441 orang menyukai DotNetJalps.

As you can see its very easy to upload multiple file in ASP.NET 4.5. Stay tuned for more. Till then happy programming. P.S.: This feature is only supported in browser who support HTML5 multiple file upload. For other browsers it will work like normal file upload control in asp.net.

www.dotnetjalps.com/2012/07/Multiple-file-upload-with-asp-net-4-5-and-Visual-Studio-2012.html

3/5

6/20/13

Multiple file upload with asp.net 4.5 and Visual Studio 2012

This entry was posted in ASP.NET 4.5 , VisualStudio , VisualStudio2012

If you enjoyed this post, make sure you subscribe to the dotnetjalps RSS feed to receive new posts in a reader or via email!. You can subcribe via putting email address in below box also

Subscribe via Email


Google+ Followers
jalpesh vad
Add to circles
Submit

Enter email address here...

Newer Post

Home

Older Post

Subscribe to: Post Comments (Atom)

272 have me in circles

View all

Sitemeter

www.dotnetjalps.com/2012/07/Multiple-file-upload-with-asp-net-4-5-and-Visual-Studio-2012.html

4/5

6/20/13

Multiple file upload with asp.net 4.5 and Visual Studio 2012

Total Pageviews

771,831

Copyright 2013 DotNetJalps

www.dotnetjalps.com/2012/07/Multiple-file-upload-with-asp-net-4-5-and-Visual-Studio-2012.html

5/5

You might also like