CopyCode The Code is as follows: <% function downloadfile (strfile)
Strfilename = strfile
Response. Buffer = true
Response. Clear
Set S = server. Createobject ("ADODB. Stream ")
S. Open
S. type = 1
On Error resume next
Set FSO = server. Createobject ("scripting. FileSystemObject ")
If not FSO. fileexists (strfilename) then
From_url = CSTR (request. servervariables ("http_referer "))
Serv_url = CSTR (request. servervariables ("SERVER_NAME "))
If mid (from_url, 8, Len (serv_url) <> serv_url then
Response. write "the file does not exist or has been deleted ."
Response. End
End if
Response. redirect request. servervariables ("http_referer ")
Response. End
End if
Fileext = mid (strfilename, limit Rev (strfilename, ".") + 1)
Select case ucase (fileext)
Case "asp", "asa", "aspx", "asax", "mdb", "php", "jsp", "shtml", "html ", "htm", "TV", "data"
From_url = CSTR (request. servervariables ("http_referer "))
Serv_url = CSTR (request. servervariables ("SERVER_NAME "))
If mid (from_url, 8, Len (serv_url) <> serv_url then
Response. write "the file does not exist or has been deleted ."
Response. End
End if
Response. redirect request. servervariables ("http_referer ")
Response. End
End select
Set F = FSO. GetFile (strfilename)
Intfilelength = f. Size
S. loadfromfile (strfilename)
If err then
From_url = CSTR (request. servervariables ("http_referer "))
Serv_url = CSTR (request. servervariables ("SERVER_NAME "))
If mid (from_url, 8, Len (serv_url) <> serv_url then
Response. write "the file data is incomplete or may be damaged ."
Response. End
End if
Response. redirect request. servervariables ("http_referer ")
Response. End
End if
Set upload = server. Createobject ("persits. Upload ")
If upload is nothing then
Response. addheader "content-disposition", "attachment; filename =" & F. Name
Response. addheader "Content-Length", intfilelength
Response. charset = "UTF-8"
Response. contenttype = "application/X-download"
Response. binarywrite S. Read
Response. Flush
S. Close
Set S = nothing
Else
Upload. sendbinary strfilename, true, "application/X-download", false
End if
End Function
%>
Call Copy codeThe Code is as follows: <% call downloadfile ("") %>