<%
'Define the function and use ADODB. Stream to read binary data.
Function ReadBinaryFile (FileName)
Const adTypeBinary = 1
Dim BinaryStream
Set BinaryStream = CreateObject ("ADODB. Stream ")
BinaryStream. Type = adTypeBinary
BinaryStream. Open
BinaryStream. LoadFromFile FileName
ReadBinaryFile = BinaryStream. Read
End Function
Response. AddHeader "Content-Disposition", "attachment?filename=2.gif" 'file name
Response. ContentType = "image/GIF" 'setting (1)
Response. Binarywrite ReadBinaryFile (server. mappath ("2.gif") 'means you read local files to prevent them from being stolen by others.
%>
(1) the following example sets the ContentType attribute to another common value.
Text/HTML.
Image/GIF image
Image/JPEG jpg image
Application/x-cdf document
Application/wma is the music type of watermelon.
For details, refer to the Web browser document or the current HTTP specification description.
In this way, you can use asp's session storage, cookies, and special functions to read HTTP headers to completely implement anti-theft connections. No cache is set here. If the traffic is huge, I want to set it to better.
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