01.
<%@ Page Language=
"VB"
%>
02.
<%@ Import
Namespace
=
"System.Web.HttpFileCollection"
%>
03.
<script runat=
"server"
>
04.
Sub
btnUpload_OnClick(sender
As
Object
, e
As
EventArgs)
05.
Dim
i
As
Integer
06.
Dim
myUpoad
As
HttpFileCollection = Request.Files
07.
Dim
myFiles
As
HttpPostedFile
08.
Me
.lblText.Text =
""
09.
For
i = 0
To
myUpoad.Count - 1
10.
myFiles = myUpoad(i)
11.
IF myUpoad.Keys(i).ToString =
"myFile"
Then
12.
If
(myFiles.FileName) <>
""
Then
13.
Dim
strFileName = System.IO.Path.GetFileName(myFiles.FileName)
14.
myFiles.SaveAs(Server.MapPath(
"Myfiles/"
& strFileName))
15.
Me
.lblText.Text =
Me
.lblText.Text & strFileName &
" Uploaded.<br>"
16.
End
If
17.
End
IF
18.
Next
19.
20.
End
Sub
21.
22.
</script>
23.
<html>
24.
<head>
25.
<title>ThaiCreate.Com ASP.NET - Upload files</title>
26.
</head>
27.
<body>
28.
<form id=
"form1"
runat=
"server"
enctype=
"multipart/form-data"
>
29.
<input name=
"myFile"
type=
"file"
><br />
30.
<input name=
"myFile"
type=
"file"
><br />
31.
<input name=
"myFile"
type=
"file"
><br />
32.
<input name=
"myFile"
type=
"file"
><br />
33.
<input name=
"myFile"
type=
"file"
><br />
34.
<input name=
"myUpload"
type=
"file"
><br />
35.
<input name=
"myUpload"
type=
"file"
><br />
36.
<input name=
"myUpload"
type=
"file"
><br />
37.
<input name=
"myUpload"
type=
"file"
><br />
38.
<input name=
"myUpload"
type=
"file"
>
39.
<input id=
"btnUpload"
type=
"button"
OnServerClick=
"btnUpload_OnClick"
value=
"Upload"
runat=
"server"
/>
40.
<hr />
41.
<asp:Label id=
"lblText"
runat=
"server"
></asp:Label>
42.
</form>
43.
</body>
44.
</html>