Use ADODB. Stream to download server files in a browser

Source: Internet
Author: User
Download. asp? File = file in the relative path
You can download this file.
<%
2    
3 call downloadFile (replace (Request ("file "),"",""),"/",""))
4    
5 Function downloadFile (strFile)
6 'make sure you are on the latest MDAC version for this to work
7 '-------------------------------------------------------------
8    
9    
10'get full path of specified file
11 strFilename = server. MapPath (strFile)
12
13
14 'clear the buffer
15 Response. Buffer = True
16 Response. Clear
17
18 'create stream
19 Set s = Server. CreateObject ("ADODB. Stream ")
20 s. Open
21
22 'set as binary
23 s. Type = 1
24
25 'load in the file
26 on error resume next
27
28
29 'check the file exists
30 Set fso = Server. CreateObject ("Scripting. FileSystemObject ")
31 if not fso. FileExists (strFilename) then
32 Response. Write ("33 Response. End
34 end if
35
36

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.