001.
<%
002.
Function
ConvertBytes(
ByRef
anBytes)
003.
Dim
lnSize
004.
Dim
lsType
005.
006.
Const
lnBYTE = 1
007.
Const
lnKILO = 1024
008.
Const
lnMEGA = 1048576
009.
Const
lnGIGA = 1073741824
010.
Const
lnTERA = 1099511627776
011.
012.
013.
014.
015.
016.
If
anBytes =
""
Or
Not
IsNumeric(anBytes)
Then
Exit
Function
017.
018.
If
anBytes < 0
Then
Exit
Function
019.
020.
021.
022.
023.
024.
If
anBytes < lnMEGA
Then
025.
026.
lnSize = (anBytes / lnKILO)
027.
lsType =
"kb"
028.
ElseIf
anBytes < lnGIGA
Then
029.
030.
lnSize = (anBytes / lnMEGA)
031.
lsType =
"mb"
032.
ElseIf
anBytes < lnTERA
Then
033.
034.
lnSize = (anBytes / lnGIGA)
035.
lsType =
"gb"
036.
Else
037.
038.
lnSize = (anBytes / lnTERA)
039.
lsType =
"tb"
040.
End
If
041.
042.
043.
044.
lnSize = FormatNumber(lnSize, 2,
True
,
False
,
True
)
045.
046.
047.
ConvertBytes = lnSize &
" "
& lsType
048.
End
Function
049.
050.
051.
052.
053.
Dim
mySmartUpload
054.
Dim
file
055.
Dim
intCount
056.
intCount=0
057.
058.
059.
060.
Set
mySmartUpload = Server.CreateObject(
"aspSmartUpload.SmartUpload"
)
061.
062.
063.
064.
mySmartUpload.Upload
065.
066.
067.
068.
For
each file
In
mySmartUpload.Files
069.
070.
071.
If
not file.IsMissing
Then
072.
073.
074.
file.SaveAs(Server.MapPath(
"Upload/"
& file.FileName))
075.
076.
077.
Size1 = ConvertBytes(file.Size)
078.
079.
080.
Response.Write(
"Name = "
& file.Name &
"<BR>"
)
081.
Response.Write(
"Size = "
& Size1 &
"<BR>"
)
082.
Response.Write(
"FileName = "
& file.FileName &
"<BR>"
)
083.
Response.Write(
"FileExt = "
& file.FileExt &
"<BR>"
)
084.
Response.Write(
"FilePathName = "
& file.FilePathName &
"<BR>"
)
085.
Response.Write(
"ContentType = "
& file.ContentType &
"<BR>"
)
086.
Response.Write(
"ContentDisp = "
& file.ContentDisp &
"<BR>"
)
087.
Response.Write(
"TypeMIME = "
& file.TypeMIME &
"<BR>"
)
088.
Response.Write(
"SubTypeMIME = "
& file.SubTypeMIME &
"<BR>"
)
089.
intCount = intCount + 1
090.
End
If
091.
Next
092.
093.
094.
095.
Response.Write(
"<BR>"
& mySmartUpload.Files.Count &
" files could be uploaded.<BR>"
)
096.
097.
098.
099.
Response.Write(intCount &
" file(s) uploaded.<BR>"
)
100.
%>