Beruflich Dokumente
Kultur Dokumente
Multiple file upload with asp.net 4.5 and Visual Studio 2012
DotNetJalps
HOME ABOUT ME
Search
Search
Follow me
SUBSCRIBE TO MY BLOG
ARCHIVE
DISCLAIMER
About Me
Multiple file upload with asp.net 4.5 and Visual Studio 2012
Posted on Monday, July 02, 2012 by jalpesh vadgama
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
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
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.
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
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
Newer Post
Home
Older Post
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
www.dotnetjalps.com/2012/07/Multiple-file-upload-with-asp-net-4-5-and-Visual-Studio-2012.html
5/5