%@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 = "
| Uploading: <%=TotalBytes%> to <%=Request.ServerVariables("HTTP_HOST")%> ... |
Huge ASP file upload progress bar |
| Progress | : <%=BytesRead%> of <%=TotalBytes%> (<%=PercBytesRead%>%) |
| Time | : <%=UploadTime%> (<%=TransferRate%>/s) |
| Time left | : <%=RestTime%> |