Let custom file download support breakpoint resume (HTTP

zhaozj2021-02-16  49

Custom file download is basically used in the following

1. Browser known types, such as avi, doc, etc. If you install the associated program locally, you will automatically open 2. Permissions management, sometimes not all people allow the download, so you need to judge when downloading. 3. Always need to put special documents to the place where the virtual directory is not visited, and the downloads of ASP and ASA.

Everyone often uses Adodb.Stream, but there is a defect, that is, it is not supported by breakpoints. I often see the red face in the flashget (ie, the breakpoint is not supported). It is also very simple to support the breakpoint renewal. As follows: Use the read http_range, then position the AdoDB.Stream, then output (the original code is originally set, theoretically, but practice can be omitted)

Function DL (f, n) on error resume next set s = createObject ("adoDb.stream") s.Mode = 3 s.Type = 1 S.Open S.LoadFromFile (f) if err.number> 0 Then Response. Status = "404" else Response.ContentType = "application / octet-stream" Response.AddHeader "Content-Disposition:", "attachment; filename =" & n Range = Mid (Request.ServerVariables ( "HTTP_RANGE"), 7) if Range = "" Then Response.binaryWrite (S.READ) Else S.Position = ClNG (split ("-") (0)) Response.binaryWrite (S.READ) end if Endiffs

Call DL (Server.Mappath ("C.avi"), "C. Avi")

At this time, you will see the red face smile, usually use in big files.

Local FlashGet test, and use FC to compare download files and the original file Fc: can't find a difference

转载请注明原文地址:https://www.9cbs.com/read-28064.html

New Post(0)