ASP如何实现点击链接弹出图片另存为功能

来源:百度知道 编辑:UC知道 时间:2024/06/21 19:16:30
请问用ASP 如何实现 点击链接弹出“图片另存为对话框”的功能?

我有个图片网站,现在网友只能鼠标右键点图片另存为保存图片。我想提升下用户体验,直接让网友点击保存链接 这几个字就能弹出保存图片的对话框,然后可以保存到本地电脑上。

我在网上找了一段代码,但是不知道如何修改。麻烦大家帮忙解决下,告诉我该如何修改。

请说明如何实现

call download(server.mappath("./test.jpg"))
Function download(File)
temp = Split(File, "\")
filename = temp(UBound(temp))
Set s = CreateObject("adodb.stream")
s.mode = 3
s.Type = 1
s.Open
s.loadfromfile(File)
data = s.Read
If IsNull(data) Then
response.Write "空"
Else
response.Clear
Response.ContentType = "application/octet-stream"
Response.AddHeader "Content-Disposition", "attachm

DOWNLOAD.HTM

<a href=download.asp?filename=download.asp>guid.asp</a>

以下另存为:DOWNLOAD.ASP

<%@language=VBscript%>
<%
Const ForReading=1
Const TristateTrue=-1
Const FILE_TRANSFER_SIZE=16384
Response.Buffer = True
Function TransferFile(path, mimeType, filename)
Dim objFileSystem, objFile, objStream
Dim char
Dim sent
send=0
TransferFile = True
Set objFileSystem = Server.CreateObject("Scripting.FileSystemObject")
Set objFile = objFileSystem.GetFile(Path)
Set objStream = objFile.OpenAsTextStream(ForReading, TristateTrue)
Response.AddHeader "content-type", mimeType
response.AddHeader "Content-Disposition","attachment;filename=" & filename
Response.AddHeader &q