< %
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 " Invalid link! " ' Preventing leeching
Response. End
End If
If Request. Cookies ( " Logined " ) = "" Then
Response. Redirect " /Login. asp " ' Login required!
End If
Function Getfilename (longname) ' /Folder1/folder2/file. asp => file. asp
While Instr (Longname, " / " )
Longname = Right (Longname, Len (Longname) - 1 )
Wend
Getfilename = Longname
End Function
Dim Stream
Dim Contents
Dim Filename
Dim Truefilename
Dim Fileext
Const Adtypebinary = 1
Filename = Request. querystring ( " Filename " )
If Filename = "" Then
Response. Write " Invalid file name! "
Response. End
End If
Fileext = Mid (Filename, Rev (Filename, " . " ) + 1 )
Select Case Ucase (Fileext)
Case " ASP " , " ASA " , " Aspx " , " Asax " , " Mdb"
Response. Write " Illegal operation! "
Response. End
End Select
Response. Clear
If Lcase ( Right (Filename, 3 )) = " GIF " Or Lcase ( Right (Filename, 3 )) = " JPG " Or Lcase ( Right (Filename, 3 )) = " PNG " Then
Response. contenttype = " Image /* " ' No download dialog box appears for image files
Else
Response. contenttype = " Application/MS-download"
End If
Response. addheader " Content-Disposition " , " Attachment; filename = " & Getfilename (request. querystring ( " Filename " ))
Set Stream = Server. Createobject ( " ADODB. Stream " )
Stream. Type = Adtypebinary
Stream. Open
If Lcase ( Right (Filename, 3 )) = " PDF " Then ' Set PDF file directory
Truefilename = " /The_pai_file_s/ " & Filename
End If
If Lcase ( Right (Filename, 3 )) = " Doc " Then ' Set the DOC file directory
Truefilename = " /My_d_o_c_file/ " & Filename
End If
If Lcase ( Right (Filename, 3 )) = " GIF " Or Lcase ( Right (Filename, 3 )) = " JPG " Or Lcase ( Right (Filename, 3 )) = " PNG " Then
Truefilename = " /All_images _/ " & Filename ' Set the image file directory
End If
Stream. loadfromfile server. mappath (truefilename)
While Not Stream. Eos
Response. binarywrite stream. Read ( 1024 * 64 )
Wend
Stream. Close
Set Stream = Nothing
Response. Flush
Response. End
% >
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