How Do I: Multiple File Uploads in ASP.NET 2

In this video I will demonstrate uploading a dynamically determined number of files to your ASP.NET application.

Presented by Joe Stagner

Duration: 16 minutes, 9 seconds

Date: 12 February 2008

Watch the video   |   Download the video   |   Get VB code  or  C# code

Video downloads: WMV | Zune | iPod | PSP | MPEG-4 | 3GP

Audio downloads: AAC | WMA | MPEG-4 | MPEG-3 | MPEG-2

Comments : 18

Leave a Comment

krishnaprasadaccot@gmail.com : On March 06, 2008 2:18 PM said:

In this video when you list the uploaded images, in uploaded folder, Only the name of the files are different,but the images looking identical . Is that a problem with my browser, or you skipped that one?

sagesmith : On March 11, 2008 12:28 PM said:

Interesting, however I fail to see any ASP.NET 2 specific innovation.  When I saw the title I thought for a minute the IE browser's common file dialog was going to support multiple file selections.  Now that would be video worthy!  It would really be a powerful enhancement and a huge step forward for browser-based applications.  I'm sure this will be a much appreciated feature for Internet sites which take a long time to upload individual files.  However for Intranet sites where the actual posting of files is quick the differences between hitting an upload button five times versus requesting 4 additional inputs then hitting an upload button is hardly worth the effort.  The frustration exits because the OS version of the common file dialog (multiple file selection, file type filtering at the dialog level, etc.) is much more robust than the browsers.

pradeepkr : On March 13, 2008 12:22 PM said:

There's an error in the C# code available for download at line 31. There's no variable named 'file', instead it should be 'uploads[i]' in place of 'file'.

JoeStagner : On March 15, 2008 12:45 PM said:

sagesmith - It's not new magic. Jst a series of techniques that developers can use.

pradeep - I know about the code error and the file is being updated. Thanks

ericdow : On March 24, 2008 1:16 PM said:

I think a tutorial on how to do multiple uploads to a database would be a good idea.

ericdow : On March 24, 2008 1:19 PM said:

Sorry there is a tutorial on doing this site.

daddyqbob50 : On March 29, 2008 4:21 PM said:

Joe

I want to upload all files from a certain client-side folder. I do not want the user to have to data enter the file names as there could be many small files. Is there any way to do this via ASP.Net? In other words how do I populate the HttpContext.Current.Request.Files collection using client script?

I have asked several ASP.Net "gurus" abou this and they do not think it is possible due to browser security restrictions. Yet the upload control does it just fine.

Thanks

Talib_dotnet : On April 03, 2008 7:01 AM said:

Hi  Joe,

Awesome video .. You  rock...

One thing  i  wanted to know is that  ..can we develop the same with ASP.NET's  FileUpload  Control    instead of HTMLFile Control....

Waiting for your reply..

Thanks..

aguila1976 : On April 24, 2008 9:09 AM said:

This code doesn´t seem to work with c# in VS2008. It works uploading one file, but not several at one time.

I did as pradeepkr and changed 'uploads[i]' in place of 'file'.

I do get some strange warning, in the end of the behind code:

catch(Exception Exp)

           {

               Span1.InnerHtml = "Upload(s) FAILED.";

           }

"The variable 'Exp' is declared but never used"

Anyone else tried it in VS2008 with c#?

mak101 : On April 25, 2008 4:29 AM said:

It's great !

However, if I just want to upload all files from a certain client-side folder, is there a video to show it?

TheDecline02 : On May 07, 2008 11:03 AM said:

This code dosen't actually work...

1. You are trying to assign HttpPostedFile to a varible called file which dosen't even exist.

2. You are only changing the filename of the saved file and not the actual file itself. So you are only uploading one file multiple times.

3. You are using Visual Studio 2008 which is .NET 3.5 and the video is labeled as ASP.NET 2.

Therefore this video is useless.

dtcs1 : On May 20, 2008 6:44 PM said:

I have tried the C# code and it does NOT WORK!

aftab : On May 24, 2008 12:07 PM said:

Thanks for this video

shweko : On June 01, 2008 7:47 PM said:

The way you called javaScript function is beautiful.

zhngmm : On June 04, 2008 5:12 PM said:

works good on me, thank you very much

dw.egun : On June 05, 2008 4:52 AM said:

Thanks for the videos. It's awesome dude......

pakpatel : On June 22, 2008 12:28 AM said:

Hi, JoeStagner

C# Program not working.So can you fix that error on buttion click event.

-Thanks

abhishek0410 : On July 02, 2008 1:43 PM said:

I want to upload all files from a certain client-side folder. I do not want the user to have to data enter the file names as there could be many small files. Is there any way to do this via ASP.Net?

or

i wan to select multiple image at once....can u tell me another way.....if i hav folder which contains images......n i browse the folder and see the all the images of that folder in thumbanil in another form and then select multiple images or select all images(like we do while selecting or deleting files on harddisk) from that form and then insert into database???? is this possible??????

Leave a Comment

You must be logged in to leave a comment. Click here to log in.

Featured Product

ComponentArt's New AJAX Approach