Custom file downloads are basically used in the following places
1. Browser-known types, such as Avi,doc, if the associated program is installed locally, it will automatically open on the browser
2. Rights management, sometimes not all people are allowed to download, so need to be in the download time to judge
3. Often need to put special files to the virtual directory inaccessible places, as well as ASP and ASA and other files download
We often use the adodb.stream, but at this time there is a flaw, that is, does not support the extension of the breakpoint.
Often see FlashGet is the red face (that is, do not support the continuation of the breakpoint) in fact, supporting the continuation of the breakpoint is also very simple. As follows:
Use the read Http_range, then position the ADODB.stream, and then output
(Original code originally also has the Content-length setting, theoretically should have, but can omit in practice)
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 (Range, "-") (0))
Response.BinaryWrite (S.read)
End If
End If
Response.End
End Function
Call DL (Server.MapPath ("C.avi"), "C.avi")
At this time you will see the red face changed to smile, generally used in large file download
Local FlashGet test passes, and FC compares downloaded files and original files
FC: No differences found
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.