chinaren验证码图片的 程序实现自动下载问
363
应该把参数如文件名,文件路径传到一个下面这个页面
在这个页面里你对文件名和路径做下更改就能不让用户看到路径了。
下面这个代码你看下。
你只要传递这个参数FileName = Request.QueryString("FileName")进来就OK了。
路径下面你可以设置,也可以自己传进来。呵这个挺好用的。
<%
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 "非法链接!" '防止盗链
response.end
end if
在这个页面里你对文件名和路径做下更改就能不让用户看到路径了。
下面这个代码你看下。
你只要传递这个参数FileName = Request.QueryString("FileName")进来就OK了。
路径下面你可以设置,也可以自己传进来。呵这个挺好用的。
<%
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 "非法链接!" '防止盗链
response.end
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
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 "无效文件名!"
Response.End
End if
FileExt = Mid(FileName, InStrRev(FileName, ".") + 1)
Select Case UCase(FileExt)
Case "ASP", "ASA", "ASPX", "ASAX", "MDB"
Response.Write "非法操作!"
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/*" '对图像文件不出现下载对话框
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))="rar" then '设置pdf类型文件目录
TrueFileName = "../admin/upsoft/"& FileName
''end if
Stream.LoadFromFile Server.MapPath(TrueFileName)
''While Not Stream.EOS
''Response.BinaryWrite Stream.Read(1024 * 64)分64块,下载,这个去掉就可以下多大都可以,加上好像不能超过5M.
''Wend
Stream.Close
Set Stream = Nothing
Response.Flush
Response.End
%>
Dim Contents
Dim FileName
Dim TrueFileName
Dim FileExt
Const adTypeBinary = 1
FileName = Request.QueryString("FileName")
if FileName = "" Then
Response.Write "无效文件名!"
Response.End
End if
FileExt = Mid(FileName, InStrRev(FileName, ".") + 1)
Select Case UCase(FileExt)
Case "ASP", "ASA", "ASPX", "ASAX", "MDB"
Response.Write "非法操作!"
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/*" '对图像文件不出现下载对话框
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))="rar" then '设置pdf类型文件目录
TrueFileName = "../admin/upsoft/"& FileName
''end if
Stream.LoadFromFile Server.MapPath(TrueFileName)
''While Not Stream.EOS
''Response.BinaryWrite Stream.Read(1024 * 64)分64块,下载,这个去掉就可以下多大都可以,加上好像不能超过5M.
''Wend
Stream.Close
Set Stream = Nothing
Response.Flush
Response.End
%>