Uploading Multiple Files using FileUpload Controls in ASP.NET

Kameswara Sarma Uppuluri
A free video tutorial from Kameswara Sarma Uppuluri
Microsoft Certified Trainer
4.4 instructor rating • 12 courses • 24,352 students

Learn more from the full course

Mastering ASP.NET 4 from scratch Using C# - Part 1

Learn How to build Dynamic Web Sites using ASP .NET 4 Step By Step

15:45:24 of on-demand video • Updated July 2020

  • Learn How to Build Dynamic Web Sites using ASP.NET
  • Learn How to work with ASP.NET Standard Controls
  • Learn How to Validate Data
  • Learn How to use SQL Server as a Back End Database to ASP.NET
  • Learn How to Create User Controls
  • Learn How to Create Custom Controls
  • Learn How to Create Master Pages
  • Learn How to develop Web Services
English [Auto] So we've seen now how to work with the file upload control that is actually letting us upload one file at a time. But what if if you wish to upload multiple files, it just one click. So to get this man, let's actually create a new page and call the size upload multiple files. Example that a SBX. So to get this done, let's have a small table with some five rows and two columns. I presque until shipped an X, and I'm actually trying to drag and drop multiple file upload controls of your choice and then I have a button here. So we have some label like file one file to file three and file for. And then I have something like, say upload all. So now I'm not sending the caption, you guys knows that. So when I click on the upload all button, let me actually paste some code which will actually upload all the files in one go. Are planning to upload these files to the B Drive's CV folder. So for this, what you have to do, first of all, I'll actually have an extra label somewhere here, which is a label file that will actually show me the messes of the files, gets uploaded successfully. So first, I have to say it's too deep to fall collection, I'm sick request dark clouds. So this will actually find out how many fine upload controls you have on this page. So I'm running to Lou. I call the zero, I use less than HFC dot count, which is four plus plus find out the very first file that you have selected. So if I would have selected some aid, I'd be we'll see here then aid or be we'll see. We'll come into this HPF offset if SBF is not Zielke K K-V followed. Zettabytes false. Not an empty file in that case. We're trying to save that fund to be derived. S.V. folder with the Aspey of dot file name and the Sloup will go on. That's actually done this and see how we can upload multiple files in one go. So I click on the browser bottom here and let's select some files, some text file and some radius list. And some topics. Today. So I've got so many four files here, so I click on upload all. So when I press F 10. You can see it has got four files. Applause. One, two, three, four. And I press after my game. So what is there an HBO right now is radios. E-mail got T X, T, press, F 10. And let's see, we have a small problem here. Let's actually fix this issue. OK, so we were actually getting an Andrew. As I have just written, HPF dot file name. So. What was actually happening? Because I'm already saving the file on my server. Indeed drives me folder. Whereas it's P of dot file name is giving the complete paths of the visitors file location. So what I'm trying to do. I have actually taken to stand up, I will namespace in my using directors and then I'm trying to say, Doc, get file name of HP of Dark File name. So this function will only the through me the actual file that the user is trying to upload, but not the complete path of the file on them is just computer's location. Let's actually see that by debugging. For example, I'm selecting some text file of your choice or some or document or excel, whatever you like. So let's have one more file and let's have a break point here. As we already have, so let's click on and upload all. So I press F 10. So you can see AJP of dot file name is actually the complete Pappe. So this video is e-mailed at TSD, available in the March fifteen folder on the client's best jobby. But Parth don't get forelimb of its P of Dot file name will actually give me only the name of the text file. So I press F 10. That's your second phone. Could fall. For everything is perfect. So the files were uploaded successfully. Let's close this window. Come back to see me folder. You can't see all those files I've just got uploaded. So that is how in this demonstration shown you how to upload multiple files with just one click.