ASP local pictures, music and other anti-theft code

Source: Internet
Author: User
Tags define function

<%
' Define function, read binary data with ADODB.stream
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" ' filename
Response.ContentType = "Image/gif" setting (1)
Response. BinaryWrite Readbinaryfile (Server.MapPath ("2.gif")) ' is that you read the presence of local files to prevent others from knowing the true path of the stolen link.

%>

(1) The following example sets the ContentType property to another common value.

Text/html, I won't tell you this.
Image/gif GIF Pictures
image/jpeg jpg Pictures
APPLICATION/X-CDF CDF Documentation
Application/wma is the watermelon which music type

You can refer to a Web browser document or the current HTTP specification

In this way, the use of ASP storage session,cookies, and read HTTP first-class special features can be completely real implementation of anti-theft links, there is no cache, if the traffic is huge, I think the setting will be better.



Related Article

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.