艾恩Ajax无刷新文件上传 如何更改为根据日期生成随机文件名
本人菜鸟使用艾恩Ajax无刷新文件上传(带进度条,无组件)由于原程序上传文件后在服务器上保存的文件名为原文件名这就导致有些文件名称相同的图片就直接覆盖了有没有用过的看怎样...
本人菜鸟 使用艾恩Ajax无刷新文件上传(带进度条,无组件) 由于原程序上传文件后在服务器上保存的文件名为原文件名 这就导致有些
文件名称相同的图片就直接覆盖了 有没有用过的 看怎样设置为根据日期生成随机文件名
上传程序:
<%
on error resume next
Server.ScriptTimeout = 9999999
Dim Upload,successful,thisFile,allFiles,upPath,path
set Upload=new AnUpLoad
Upload.openProcesser=true '打开进度条显示
Upload.SingleSize=512*1024*1024 '设置单个文件最大上传限制,按字节计;默认为不限制,本例为512M
Upload.MaxSize=1024*1024*1024 '设置最大上传限制,按字节计;默认为不限制,本例为1G
Upload.Exe="*" '设置允许上传的扩展名
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,allFiles
else
upload.setApp "faild",1,0,"没有上传任何文件"
end if
end if
if err then upload.setApp "faild",1,0,err.description
set Upload=nothing
response.end
%>
类:
'==============================
'根据日期生成随机文件名
'==============================
Private Function Getname()
Dim y, m, d, h, mm, S, r
Randomize
y = Year(Now)
m = Month(Now): If m < 10 Then m = "0" & m
d = Day(Now): If d < 10 Then d = "0" & d
h = Hour(Now): If h < 10 Then h = "0" & h
mm = Minute(Now): If mm < 10 Then mm = "0" & mm
S = Second(Now): If S < 10 Then S = "0" & S
r = 0
r = CInt(Rnd() * 1000)
If r < 10 Then r = "00" & r
If r < 100 And r >= 10 Then r = "0" & r
Getname = y & m & d & h & mm & S & r
End Function
不知道修改哪一段 谢谢 展开
文件名称相同的图片就直接覆盖了 有没有用过的 看怎样设置为根据日期生成随机文件名
上传程序:
<%
on error resume next
Server.ScriptTimeout = 9999999
Dim Upload,successful,thisFile,allFiles,upPath,path
set Upload=new AnUpLoad
Upload.openProcesser=true '打开进度条显示
Upload.SingleSize=512*1024*1024 '设置单个文件最大上传限制,按字节计;默认为不限制,本例为512M
Upload.MaxSize=1024*1024*1024 '设置最大上传限制,按字节计;默认为不限制,本例为1G
Upload.Exe="*" '设置允许上传的扩展名
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,allFiles
else
upload.setApp "faild",1,0,"没有上传任何文件"
end if
end if
if err then upload.setApp "faild",1,0,err.description
set Upload=nothing
response.end
%>
类:
'==============================
'根据日期生成随机文件名
'==============================
Private Function Getname()
Dim y, m, d, h, mm, S, r
Randomize
y = Year(Now)
m = Month(Now): If m < 10 Then m = "0" & m
d = Day(Now): If d < 10 Then d = "0" & d
h = Hour(Now): If h < 10 Then h = "0" & h
mm = Minute(Now): If mm < 10 Then mm = "0" & mm
S = Second(Now): If S < 10 Then S = "0" & S
r = 0
r = CInt(Rnd() * 1000)
If r < 10 Then r = "00" & r
If r < 100 And r >= 10 Then r = "0" & r
Getname = y & m & d & h & mm & S & r
End Function
不知道修改哪一段 谢谢 展开
展开全部
在这个文件开始大概40行内,有一行“newName = 1 '是否已新文件名保存文件,0 = 重新命名,1 = 原文件名”,改成0就可以了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
我有修改好的 但是瞎改的 不过完全可以使用的 文件UpLoad_Class.asp 行411
if(arg.length==1){Path = arg[0];Option=0;OverWrite=true;}
if(arg.length==2){Path = arg[0];Option=0;OverWrite=true;}
if(arg.length==3){Path = arg[0];Option=0;OverWrite=arg[2];}
Option 全部改为0 因为下面有个判断语句 就是根据那个瞎改的
if(Option==1){
Path = Path + this.LocalName;this.FileName = this.LocalName;
}else{
if(Option==-1 && this.UserSetName!=""){
Path = Path + this.UserSetName;this.FileName = this.UserSetName;
}else{
Path = Path + this.NewName;this.FileName = this.NewName;
}
}
if(arg.length==1){Path = arg[0];Option=0;OverWrite=true;}
if(arg.length==2){Path = arg[0];Option=0;OverWrite=true;}
if(arg.length==3){Path = arg[0];Option=0;OverWrite=arg[2];}
Option 全部改为0 因为下面有个判断语句 就是根据那个瞎改的
if(Option==1){
Path = Path + this.LocalName;this.FileName = this.LocalName;
}else{
if(Option==-1 && this.UserSetName!=""){
Path = Path + this.UserSetName;this.FileName = this.UserSetName;
}else{
Path = Path + this.NewName;this.FileName = this.NewName;
}
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询