发现还没有aspupload这个组件的,这两样功能的解决方案,现把我的改进方案写在这里!谢谢
关于aspupload上传组件,文件重命名,进度条的问题解决方案!
共用到4个文件,分别是1.asp,2.asp,bar.asp,framebar.asp
运行第一个文件:1.asp,执行上传操作!
复制代码 代码如下:
<%
'''进度条
dimSPid,PID,barref
SetUploadProgress=Server.CreateObject("Persits.UploadProgress")
SPid=UploadProgress.CreateProgressID()
PID="PID="&SPid
barref="framebar.asp?to=10&"&PID
%>
<SCRIPTlanguage="javascript">
<>
</SCRIPT>
<html>
<head></head>
<body>
<formmethod="post"enctype="multipart/form-data"action="2.asp?<%=PID%>"name="upfile"OnSubmit="returnShowProgress();">
选择要上传的文件:<br>
<inputtype=filename="filename"><br>
<inputtype=submitvalue="上传"onclick="returnisPic()">
</form>
</body>
</html>
2.asp
复制代码 代码如下:
<%
SetUpload=Server.CreateObject("Persits.Upload")
'Preventoverwriting
Upload.OverwriteFiles=False
'Weusememoryuploads,文件大小限制,单位:b
Upload.SetMaxSize1*1024*1024*1024,true
ifRequest.QueryString("PID")=""then
Upload.ProgressID="010D60EB00C5AA4B"
else
Upload.ProgressID=Request.QueryString("PID")
endif
OnErrorResumeNext
'Savetomemory保存到内存
Upload.Save
IfErr.Number=8Then
Response.Write"文件大于1G"
EndIf
'为使文件不重名,用系统时间+随机数,作为文件名
DimranNum
randomize
ranNum=int(999*rnd)
CreateName=year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum
NewName=CreateName
'保存文件路径
articlepath=Server.MapPath("upload1")
ForEachFileinUpload.Files
FileExt=Lcase(replace(File.ext,".",""))
'服务器端判断文件类型,动网论坛的判断方式
IfCheckFileExt(FileExt)=falsethen
Response.write"文件格式不正确,或不能为空[<ahref=#onclick=history.go(-1)>重新上传</a>]"
else
File.SaveAsarticlepath&"/"&NewName&File.ext
Response.Write"Newname:"&File.FileName&"<BR>"
EndIf
Next
%>
<%
'服务器端判断文件类型,动网论坛的判断方式
PrivateFunctionCheckFileExt(FileExt)
IfFileExt=""orIsEmpty(FileExt)Then
CheckFileExt=false
ExitFunction
EndIf
IfLcase(FileExt)="asp"orLcase(FileExt)="asa"orLcase(FileExt)="aspx"then
CheckFileExt=false
ExitFunction
EndIf
IfLcase(FileExt)="gif"orLcase(FileExt)="jpg"orLcase(FileExt)="png"orLcase(FileExt)="swf"orLcase(FileExt)="bmp"then
CheckFileExt=true
ExitFunction
Else
CheckFileExt=false
EndIf
EndFunction
%>
当前1/2页12下一页阅读全文