📄 ixs_uploadaspup3.asp
字号:
<%@ EnableSessionState = False %>
<%
Response.Expires = -1
Dim UploadPID
UploadPID = Trim(Request.QueryString("UploadPID"))
' AspUpload 进度数据输出
' 说明:不直接读取完成百分比是为了在客户端脚本中兼容无组件上传类的读取方法
Dim UploadProgress
' 因为单位的关系所以需要转换一下
Dim oTs, oRs, oPs
Dim Format, Bar_Content
Set UploadProgress = Server.CreateObject("Persits.UploadProgress")
Format = "%V" ' 获取总大小 转换成字节
oTs = FormatSize(UploadProgress.FormatProgress(UploadPID, 10, "", Format))
Format = "%U" ' 获取当前大小 转换成字节
oRs = FormatSize(UploadProgress.FormatProgress(UploadPID, 10, "", Format))
Format = "%P" ' 获取上传进度 如果进度时100%,则强制当前大小等于总大小,以避免进度条长时间不关闭
oPs = CInt(RegExpSearch("\d+(\.)?\d+", UploadProgress.FormatProgress(UploadPID, 10, "", Format), 0, ""))
' 到达100不太准确,稍微小一点也不影响效果
If oPs >= 98 Then oRs = oTs
'Bar_Content = "lngTotalSize=" & oTs & ";lngReadSize=" & oRs & ";"
Bar_Content = "<script type=""text/javascript"">try{parent.lngTotalSize=" & oTs & ";parent.lngReadSize=" & oRs & ";}catch(e){}</script>"
Response.Write(Bar_Content)
Response.Flush()
Set UploadProgress = Nothing
' ============================================
' 格式化文件大小,转换成字节
' ============================================
Function FormatSize(tSize)
FormatSize = 0
' 清理其中可能存在的HTML标记
tSize = RegExpFilter("<.+?>", tSize, 1, "")
' 按照不同的大小规则来转换
If InStr(UCase(tSize), "G") > 0 Then
FormatSize = Abs(RegExpSearch("\d+(\.)?\d+", tSize, 0, "")) * 1024 * 1024 * 1024
ElseIf InStr(UCase(tSize), "M") > 0 Then
FormatSize = Abs(RegExpSearch("\d+(\.)?\d+", tSize, 0, "")) * 1024 * 1024
ElseIf InStr(UCase(tSize), "K") > 0 Then
FormatSize = Abs(RegExpSearch("\d+(\.)?\d+", tSize, 0, "")) * 1024
End If
End Function
' ============================================
' 按照指定的正则表达式替换字符
' ============================================
Public Function RegExpFilter(Patrn, Str, sType, ReplaceWith)
Dim RegEx
Set RegEx = New RegExp
If sType = 1 Then
RegEx.Global = True
Else
RegEx.Global = False
End If
RegEx.Pattern = Patrn
RegEx.IgnoreCase = True
RegExpFilter = RegEx.Replace(Str, ReplaceWith)
End Function
' ============================================
' 按照指定的正则表达式返回字符
' ============================================
Public Function RegExpSearch(Patrn, Str, sType, Spacer)
Dim RegEx, Match, Matches , RetStr, i
i = 0
Set RegEx = New RegExp
RegEx.Pattern = Patrn
RegEx.IgnoreCase = True
RegEx.Global = True
Set Matches = RegEx.Execute(Str)
For Each Match In Matches
i = i + 1
If sType = 0 Then
RetStr = RetStr & Match.Value
If i < Matches.Count Then RetStr = RetStr & Spacer
Else
RetStr = RetStr & Match.Value
If i < Matches.Count Then RetStr = RetStr & Spacer
If sType = i Then Exit For
End If
Next
RegExpSearch = RetStr
End Function
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -