During IE's document link, if you encounter a document supported by OLE, IE will automatically call the corresponding program to open it. Sometimes this function is not what we need, although we can remind users to right-click --> "save the target .... "command to download the document, but this is not very friendly after all. This article describes how to use the FSO and Stream methods to directly download the document for IE.
<% @ Language = vbscript codepage = 65001%>
<%
'Filename must be input
If Request ("Filename") = "" then
Response. write "Else
Call downloadFile (replace (Request ("Filename "),"",""),"/",""))
Function downloadFile (strFile)
'Make sure you are on the latest MDAC version for this to work
'Get full path of specified file
StrFilename = server. MapPath (strFile)
'Clear the buffer
Response. Buffer = True
Response. Clear
'Create stream
Set s = Server. CreateObject ("ADODB. Stream ")
S. Open
'Set as binary
S. Type = 1
'Load in the file
On error resume next
'Check the file exists
Set fso = Server. CreateObject ("Scripting. FileSystemObject ")
If not fso. FileExists (strFilename) then
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