Multiple File Upload With ASP.net 4

Embed Size (px)

Citation preview

  • 7/28/2019 Multiple File Upload With ASP.net 4

    1/5

    6/20/13 Multiple file upload with asp.net 4.5 and Visual Studio 2012

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

    Search Search

    Follow 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 ofVisual Studio 2012 feature

    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.

    Here you can see that I have given file upload control

    id as multipleFile and I have set AllowMultiple file to

    Subscribe via Email

    Enter email address here...

    Submit

    About Me

    JALPESH

    VADGAMA

    Development Manager

    @ Elan Emerging

    Technologies,

    Ahmedabad | Microsoft

    MVP(Visual C#) |

    Blogger | Writer. Having

    9 years of experience

    in NET Technologies.

    VIEW MY

    COMPLETE

    PROFILE

    FollowFollow @jalpesh@jalpesh

    Subscribe in a

    reader

    DotNetJalpsMy experiments with Microsoft.NET Technologies.

    HOME ABOUT ME SUBSCRIBE TO MY BLOG ARCHIVE

    VISUAL STUDIO 2012 VISUAL STUDIO EXTENSIONS DISCLAIMER

    12

  • 7/28/2019 Multiple File Upload With ASP.net 4

    2/5

    6/20/13 Multiple file upload with asp.net 4.5 and Visual Studio 2012

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

    true. I have also taken one button for uploading file.For

    this example I am going to upload file in images folder.

    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.

    Here in the above code you can see that I have

    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

    following.

    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

    Why we should

    write blogs and

    do community

    work

    Model binding with

    ASP.NET 4.5

    and Visual

    Studio 2...

    Free Visual Studio

    2012 eBookfrom Telerik

    Dividing

    web.config into

    multiple files in

    asp.net...

    Event handler

    generation inVisual Studio

    2012

    Multiple file upload

    1234567891011

    protectedvoiduploadFile_Click(objectsend{ if(multipleFile.HasFiles) { foreach(HttpPostedFile uploadedFile

    { uploadedFile.SaveAs(System.IO.P Response.Write("File uploaded s } }}

    ?

    http://www.dotnetjalps.com/2012/07/Multiple-file-upload-with-asp-net-4-5-and-Visual-Studio-2012.html#http://www.dotnetjalps.com/2012/07/Multiple-file-upload-with-asp-net-4-5-and-Visual-Studio-2012.htmlhttp://www.dotnetjalps.com/2012/07/Event-handler-generation-in-Visual-Studio-2012.htmlhttp://www.dotnetjalps.com/2012/07/Dividing-web-config-into-multiple-files-in-asp-net.htmlhttp://www.dotnetjalps.com/2012/07/Free-Visual-Studio-2012-eBook-from-Telerik.htmlhttp://www.dotnetjalps.com/2012/07/Model-binding-with-ASP-NET-45-and-Visual-Studio-2012.htmlhttp://www.dotnetjalps.com/2012/07/Why-we-should-write-blogs-and-do-community-work.htmlhttp://www.dotnetjalps.com/2012/07/Multiple-file-upload-with-asp-net-mvc-and-HTML5.htmlhttp://www.dotnetjalps.com/2012_07_01_archive.htmlhttp://void%280%29/http://www.dotnetjalps.com/2012_08_01_archive.htmlhttp://void%280%29/http://www.dotnetjalps.com/2012_09_01_archive.htmlhttp://void%280%29/http://www.dotnetjalps.com/2012_10_01_archive.htmlhttp://void%280%29/http://www.dotnetjalps.com/2012_12_01_archive.htmlhttp://void%280%29/http://www.dotnetjalps.com/search?updated-min=2012-01-01T00:00:00%2B05:30&updated-max=2013-01-01T00:00:00%2B05:30&max-results=50http://void%280%29/http://www.dotnetjalps.com/search?updated-min=2013-01-01T00:00:00%2B05:30&updated-max=2014-01-01T00:00:00%2B05:30&max-results=50http://void%280%29/http://feeds.feedburner.com/DotNetJalpshttp://lh6.ggpht.com/-5NfyUAq0hF4/T_ChijmfrSI/AAAAAAAABZ0/-dYd9dQ33nE/s1600-h/MultipleUploadFileswithASP.NET%25255B3%25255D.png
  • 7/28/2019 Multiple File Upload With ASP.net 4

    3/5

    6/20/13 Multiple file upload with asp.net 4.5 and Visual Studio 2012

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

    As you can see now it has successfully upload file and

    you can see in windows explorer like following.

    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.

    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)

    Temukan kami di

    Facebook

    DotNetJal

    Suka

    441 orang menyukai

    DotNetJalps.

    http://www.dotnetjalps.com/2012/07/Multiple-file-upload-with-asp-net-4-5-and-Visual-Studio-2012.htmlhttp://www.facebook.com/cospilixhttp://www.facebook.com/houssem.intern0thttp://www.facebook.com/preetam.sharma.526875http://www.dotnetjalps.com/search?updated-min=2006-01-01T00:00:00%2B05:30&updated-max=2007-01-01T00:00:00%2B05:30&max-results=35http://void%280%29/http://www.dotnetjalps.com/search?updated-min=2007-01-01T00:00:00%2B05:30&updated-max=2008-01-01T00:00:00%2B05:30&max-results=50http://void%280%29/http://www.dotnetjalps.com/search?updated-min=2008-01-01T00:00:00%2B05:30&updated-max=2009-01-01T00:00:00%2B05:30&max-results=25http://void%280%29/http://www.dotnetjalps.com/search?updated-min=2009-01-01T00:00:00%2B05:30&updated-max=2010-01-01T00:00:00%2B05:30&max-results=49http://void%280%29/http://www.dotnetjalps.com/search?updated-min=2010-01-01T00:00:00%2B05:30&updated-max=2011-01-01T00:00:00%2B05:30&max-results=50http://void%280%29/http://www.dotnetjalps.com/search?updated-min=2011-01-01T00:00:00%2B05:30&updated-max=2012-01-01T00:00:00%2B05:30&max-results=50http://void%280%29/http://www.dotnetjalps.com/2012_01_01_archive.htmlhttp://void%280%29/http://www.dotnetjalps.com/2012_02_01_archive.htmlhttp://void%280%29/http://www.dotnetjalps.com/2012_03_01_archive.htmlhttp://void%280%29/http://www.dotnetjalps.com/2012_04_01_archive.htmlhttp://void%280%29/http://www.dotnetjalps.com/2012_05_01_archive.htmlhttp://void%280%29/http://www.dotnetjalps.com/2012_06_01_archive.htmlhttp://void%280%29/http://www.dotnetjalps.com/2012/07/Quick-tour-visual-studio-2012-features-so-far-what-is-new.htmlhttp://www.dotnetjalps.com/2012/07/third-year-in-row-microsoft-mvp-again-dotnetjalps.htmlhttp://www.dotnetjalps.com/2012/07/Multiple-file-upload-with-asp-net-4-5-and-Visual-Studio-2012.htmlhttp://www.facebook.com/cospilixhttp://www.facebook.com/ramesh.kore.3363http://www.facebook.com/houssem.intern0thttp://www.facebook.com/sunillshahhttp://www.facebook.com/preetam.sharma.526875http://www.facebook.com/DotNetJalpshttp://www.facebook.com/DotNetJalpshttp://www.facebook.com/DotNetJalpshttp://lh6.ggpht.com/-l9NAWnzqYsk/T_ChqXc8C8I/AAAAAAAABaU/GpIQOLO9AsQ/s1600-h/FileUploadedAfter%25255B4%25255D.pnghttp://lh5.ggpht.com/-M_93_vumewM/T_ChmgKqYlI/AAAAAAAABaE/e-Ae7Nl1xIc/s1600-h/SucessfulMessage%25255B3%25255D.png
  • 7/28/2019 Multiple File Upload With ASP.net 4

    4/5

    6/20/13 Multiple file upload with asp.net 4.5 and Visual Studio 2012

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

    Newer Post Older Post

    Subscribe via Email

    Enter email address here...

    Submit

    This entry was posted inASP.NET 4.5 , VisualStudio ,

    VisualStudio2012

    If you enjoyed this post, make sure you subscribeto the dotnetjalps RSS feedto receive new posts

    in a reader or via email!. You can subcribe via

    putting email address in below box also

    Home

    Subscribe to: Post Comments (Atom)

    Google+ Followers

    jalpesh vad

    272 have

    me in

    circles

    View

    all

    Add to circles

    Sitemeter

    http://www.alexa.com/data/details/main?url=http://www.dotnetjalps.comhttp://www.alexa.com/siteinfo/www.dotnetjalps.comhttp://www.sitemeter.com/stats.asp?site=s25jalpeshhttp://www.dzone.com/aboutmvbhttps://mvp.support.microsoft.com/profile/jalpeshhttps://plus.google.com/100040283480866309914/op/followershttps://plus.google.com/102640192862524788875https://plus.google.com/109563029414351248319https://plus.google.com/108381683513732598682https://plus.google.com/110717070640265516721https://plus.google.com/107061795125769664574https://plus.google.com/111038882618907135298https://plus.google.com/113731462006830435501https://plus.google.com/113428263471420295021https://plus.google.com/100040283480866309914http://www.dotnetjalps.com/feeds/7837628835211505656/comments/defaulthttp://www.dotnetjalps.com/http://feeds.feedburner.com/DotNetJalpshttp://www.dotnetjalps.com/search/label/VisualStudio2012http://www.dotnetjalps.com/search/label/VisualStudiohttp://www.dotnetjalps.com/search/label/ASP.NET%204.5http://www.dotnetjalps.com/2012/07/Multiple-file-upload-with-asp-net-4-5-and-Visual-Studio-2012.htmlhttp://www.dotnetjalps.com/2012/07/Multiple-file-upload-with-asp-net-4-5-and-Visual-Studio-2012.htmlhttp://www.dotnetjalps.com/2012/07/third-year-in-row-microsoft-mvp-again-dotnetjalps.htmlhttp://www.dotnetjalps.com/2012/07/Event-handler-generation-in-Visual-Studio-2012.html
  • 7/28/2019 Multiple File Upload With ASP.net 4

    5/5

    6/20/13 Multiple file upload with asp.net 4.5 and Visual Studio 2012

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

    Total Pageviews

    771,831

    Copyright 2013 DotNetJalps

    http://www.dotnetjalps.com/