<%@EnableSessionState=False%> <% 'Session must be off to work correctly. Const RefreshTime = 1'Seconds 'Upload ID must be defined. 'Redirect to base script without the parameter. if Request.QueryString("UploadID") = "" then response.redirect "Upload.ASP" end if Server.ScriptTimeout = 10 'Using Huge-ASP file upload 'Dim Form: Set Form = Server.CreateObject("ScriptUtils.ASPForm") 'Using Pure-ASP file upload Dim Form: Set Form = New ASPForm %><% '{b}Get current uploading form with UploadID. on error resume next Set Form = Form.getForm(Request.QueryString("UploadID"))'{/b} if Err = 0 then '?Completted 0 = in progress on error goto 0 if Form.BytesRead>0 then'Upload was started. Dim UpStateHTML 'Get currently uploadded filenames and sizes UpStateHTML = FileStateInfo(Form) end if 'Do not cache output data of this script. response.cachecontrol = "no-cache" response.AddHeader "Pragma","no-cache" 'This script is progress bar. 'There is a good idea to refresh it to show progress more than once :-). 'Refresh time is in second response.addheader "Refresh", RefreshTime 'Count progress indicators ' - percent and total read, total bytes, etc. Dim PercBytesRead, PercentRest, BytesRead, TotalBytes Dim UploadTime, RestTime, TransferRate BytesRead = Form.BytesRead TotalBytes = Form.TotalBytes if TotalBytes>0 then 'upload started. PercBytesRead = int(100*BytesRead/TotalBytes) PercentRest = 100-PercBytesRead if Form.ReadTime>0 then TransferRate = BytesRead / Form.ReadTime if TransferRate>0 then RestTime = FormatTime((TotalBytes-BytesRead) / TransferRate) TransferRate = FormatSize(1000 * TransferRate) else 'upload not started. RestTime = "?" PercBytesRead = 0 PercentRest = 100 TransferRate = "?" end if 'Create graphics progress bar. 'The bar is created with blue (TDsread, completted) / blank (TDsRemain, remaining) TD cells. Dim TDsread, TDsRemain TDsread = " " TDsRemain = " " 'Format output values. UploadTime = FormatTime(Form.ReadTime) TotalBytes = FormatSize(TotalBytes) BytesRead = FormatSize(BytesRead) 'Simple utilities. 'Formats milisedond to m:ss format. Function FormatTime(byval ms) ms = 0.001 * ms 'get second FormatTime = (ms \ 60) & ":" & right("0" & (ms mod 60),2) & "s" End Function 'Format bytes to a string Function FormatSize(byval Number) if isnumeric(Number) then if Number > &H100000 then'1M Number = FormatNumber (Number/&H100000,1) & "MB" elseif Number > 1024 then'1k Number = FormatNumber (Number/1024,1) & "kB" else Number = FormatNumber (Number,0) & "B" end if end if FormatSize = Number End Function Function FileStateInfo(Form) 'enumerate uploaded fields. 'and build report about its current state. On Error Resume Next Dim UpStateHTML, Field for each Field in Form.Files 'Get field name UpStateHTML = UpStateHTML & "FieldName:" & Field.Name if Field.InProgress then 'this field is in progress now. UpStateHTML = UpStateHTML & ", uploading: " & Field.FileName elseif Field.Length>0 then 'This field was succefully uploaded. UpStateHTML = UpStateHTML & ", received: " & Field.FileName & ", " & FormatSize(Field.Length) end if UpStateHTML = UpStateHTML & "
" Next FileStateInfo = UpStateHTML End Function 'Some comments for HTML 'Page-Enter and revealTrans is for Flicker-Free progress. %> <%=PercBytesRead%>% completted - upload to <%=Request.ServerVariables("HTTP_HOST")%> in progress
Uploading:
<%=TotalBytes%> to <%=Request.ServerVariables("HTTP_HOST")%> ...
Huge ASP file upload progress bar
<%=TDsread%><%=TDsRemain%>
Progress : <%=BytesRead%> of <%=TotalBytes%> (<%=PercBytesRead%>%) 
Time : <%=UploadTime%> (<%=TransferRate%>/s)
Time left : <%=RestTime%>


<%=UpStateHTML%> <% else 'if Err = 0 then upload finished %> Upload Finished <% End If'if Err = 0 then %>