发现还没有aspupload这个组件的,这两样功能的解决方案,现把我的改进方案写在这里!谢谢
关于aspupload上传组件,文件重命名,进度条的问题解决方案!
共用到4个文件,分别是1.asp,2.asp,bar.asp,framebar.asp
运行第一个文件:1.asp,执行上传操作!
'''进度条
dim SPid,PID,barref
Set UploadProgress = Server.CreateObject("Persits.UploadProgress")
SPid = UploadProgress.CreateProgressID()
PID = "PID=" & SPid
barref = "framebar.asp?to=10&" & PID
%>
"name="upfile"OnSubmit="return ShowProgress();">选择要上传的文件:
2.asp
Set Upload = Server.CreateObject("Persits.Upload")
' Prevent overwriting
Upload.OverwriteFiles = False
' We use memory uploads, 文件大小限制 ,单位:b
Upload.SetMaxSize 1*1024*1024*1024, true
if Request.QueryString("PID") = "" then
Upload.ProgressID="010D60EB00C5AA4B"
else
Upload.ProgressID=Request.QueryString("PID")
end if
On Error Resume Next
' Save to memory 保存到内存
Upload.Save
If Err.Number = 8 Then
Response.Write "文件大于1G"
End If
'为使文件不重名,用系统时间+随机数,作为文件名
Dim ranNum
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")
For Each File in Upload.Files
FileExt=Lcase(replace(File.ext,".",""))
'服务器端判断文件类型,动网论坛的判断方式
If CheckFileExt(FileExt)=false then
Response.write "文件格式不正确,或不能为空 [ 重新上传 ]"
else
File.SaveAs articlepath & "/" & NewName & File.ext
Response.Write "New name: " & File.FileName & "
"
End If
Next
%>
'服务器端判断文件类型,动网论坛的判断方式
Private Function CheckFileExt(FileExt)
If FileExt="" or IsEmpty(FileExt) Then
CheckFileExt=false
Exit Function
End If
If Lcase(FileExt)="asp" or Lcase(FileExt)="asa" or Lcase(FileExt)="aspx" then
CheckFileExt=false
Exit Function
End If
If Lcase(FileExt)="gif" or Lcase(FileExt)="jpg" or Lcase(FileExt)="png" or Lcase(FileExt)="swf" or Lcase(FileExt)="bmp" then
CheckFileExt=true
Exit Function
Else
CheckFileExt=false
End If
End Function
%>
bar.asp
Response.Expires = -1
PID = Request("PID")
TimeO = Request("to")
Set UploadProgress = Server.CreateObject("Persits.UploadProgress")
format = "
%T%t%B3%T 速度:(%S/秒) 估计剩余时间:%R %r%U / %V(%P)%l%t"
bar_content = UploadProgress.FormatProgress(PID, TimeO, "#00007F", format)
If "" = bar_content Then
%>
Upload Finishedfunction CloseMe()
{
window.parent.close();
return true;
}
Else ' Not finished yet
%>
Response.Write Request.ServerVariables("URL")
Response.Write "?to=" & TimeO & "&PID=" & PID %>">
Uploading Files...body,td {font-family:Tahoma; font-size: 8pt }
td.spread {font-size: 6pt; line-height:6pt }
td.brick {font-size:6pt; height:12px}
framebar.asp
正在上传--" title="Uploading" noresize scrolling=no
frameborder=0 framespacing=10 width=369 height=115>
取消上传 |