问题描述
- ASP无组件上传怎样命名为原文件名+随机数啊
-
<%@LANGUAGE="VBSCRIPT"%>
<%Response.buffer=True%><%
Dim MM_editAction
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)
End If' boolean to abort record edit
Dim MM_abortEdit
MM_abortEdit = false'====================================================
Dim objUpload,objFile,strPicPath,intRandom,strFileExt
Set objUpload = new upload_fileIf (CStr(objUpload.oForm("MM_insert")) = "form1") Then
If (Not MM_abortEdit) Then
Set objFile = objUpload.File("attachment")
If objFile.FileSize > 0 Then
randomize Timer
intRandom = int(90000 * rnd) + 10000
strFileExt = Lcase(objFile.FileExt)
strPicPath =year(now)&month(now)&day(now)&intRandom&"."&strFileExtobjFile.SaveToFile Server.MapPath("/upload/" & strPicPath)
else
strPicPath=""
end if
'===================================================================================下面是UPLOAD.ASP的代码
<%
on error resume next
Server.ScriptTimeout = 9999999
Dim Upload,successful,thisFile,allFiles,upPath,path
set Upload=new AnUpLoad
Upload.openProcesser=true '打开进度条显示
Upload.SingleSize=clng(500 * 1024)*1024 '设置单个文件最大上传限制,按字节计;默认为不限制,本例为512M
Upload.MaxSize=clng(500 * 1024)*1024 '设置最大上传限制,按字节计;默认为不限制,本例为1G
Upload.Exe="rar|jpg|bmp|gif|iso|zip|txt|doc|docx|xls|xlsx" '设置允许上传的扩展名
Upload.GetData()
if Upload.ErrorID>0 then
upload.setApp "faild",1,0 ,Upload.description
else
if Upload.files(-1).count>0 then
dim str
for each file in Upload.files(-1)
upPath=request.querystring("path")
path=server.mappath(upPath)
set tempCls=Upload.files(file)
upload.setApp "saving",Upload.TotalSize,Upload.TotalSize,tempCls.FileName
successful=tempCls.SaveToFile(path,1)
thisFile="{name:'" & tempCls.FileName & "',size:" & tempCls.Size & "}"
allFiles=allFiles & thisFile & ","
set tempCls=nothing
next
upload.setApp "saved",Upload.TotalSize,Upload.TotalSize,mid(allFiles,1,len(allFiles)-1)
else
upload.setApp "faild",1,0,"没有上传任何文件"
end if
end if
if err then upload.setApp "faild",1,0,err.description
set Upload=nothing
%>目前的命名方式是日期+随机数,我想要实现的是原名+日期+随机数,请高手帮着改下啊