非常谢谢楼上的。。就是不知道怎么改。。能帮忙看看吗。代码如下。。
' 无组上传类
Sub DoUpload_Class()
On Error Resume Next
Dim oUpload, oFile
' 建立上传对象
Set oUpload = New upfile_class
' 取得上传数据,限制最大上传
oUpload.GetData(nAllowSize*1024)
If oUpload.Err > 0 Then
Select Case oUpload.Err
Case 1
Call OutScript("parent.UploadError('请选择有效的上传文件!')")
Case 2
Call OutScript("parent.UploadError('你上传的文件总大小超出了最大限制(" & nAllowSize & "KB)!')")
End Select
Response.End
End If
Set oFile = oUpload.File("uploadfile")
sFileExt = LCase(oFile.FileExt)
Call CheckValidExt(sFileExt)
sOriginalFileName = oFile.FileName
sSaveFileName = GetRndFileName(sFileExt)
oFile.SaveToFile Server.Mappath(sUploadDir & sSaveFileName)
Set oFile = Nothing
Set oUpload = Nothing
End Sub
' 取随机文件名
Function GetRndFileName(sExt)
Dim sRnd
Randomize
sRnd = Int(900 * Rnd) + 100
GetRndFileName = year(now) & month(now) & day(now) & hour(now) & minute(now) & second(now) & sRnd & "." & sExt
End Function
' 输出客户端脚本
Sub OutScript(str)
Response.Write "<script language=javascript>" & str & ";history.back()</script>"
End Sub
Sub OutScriptNoBack(str)
Response.Write "<script language=javascript>" & str & "</script>"
End Sub
' 检测扩展名的有效性
Sub CheckValidExt(sExt)
Dim b, i, aExt
b = False
aExt = Split(sAllowExt, "|")
For i = 0 To UBound(aExt)
If LCase(aExt(i)) = sExt Then
b = True
Exit For
End If
Next
If b = False Then
OutScript("parent.UploadError('提示:\n\n请选择一个有效的文件,\n支持的格式有("+sAllowExt+")!')")
Response.End
End If
End Sub
[此贴子已经被作者于2006-7-7 11:59:49编辑过]