1
Oct

Upload multiple file through fileuploadcontrol

   Posted by: admin   in .Net Emperor

Hello Friends

Here i write some thing for .net devlopers who need to upload multiple file with help of fileupload control in asp .net. nice thing about this code is you don`t have to create as much button as your fileupload control you add in your aspx page. this code gives you upload all files with single click it is same as yahoo mail attach file in mail.

Please see below code and follow that all.

Make One Upload.aspx page and paste this code in that page.

Add Five or six or as you want fileupload control and one button with id “btnUpload” and create one click event for that button. paste below code in that event.

Protected Sub btnUpload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpload.Click
Try
Dim FC As HttpFileCollection = Request.Files
For i As Integer = 0 To FC.Count - 1
Dim Upload As HttpPostedFile = FC(i)
If Upload.ContentLength > 0 Then
Upload.SaveAs(Server.MapPath(”~/MemberSection/plans”) & “/” & System.IO.Path.GetFileName(Upload.FileName))
End If
Next i
Catch ex As Exception
Response.Write(”Error:
” & ex.Message)
End Try
End Sub

Enjoy Multiple file upload with single click. 

 

 

 

Tags:

This entry was posted on Wednesday, October 1st, 2008 at 5:04 am and is filed under .Net Emperor. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

One comment

tejas
 1 

thanks man it`s very nice code

October 2nd, 2008 at 12:44 am

Leave a reply

Name (*)
Mail (will not be published) (*)
URI
Comment