我正在使用 jquery $.post 函数来调用一个 asp 脚本。该脚本需要复制我在服务器上的文件并将其保存在客户端计算机上。我希望用户使用典型的保存窗口将文件保存在他们想要的位置,而不是在 asp.xml 中硬编码路径。有什么建议吗?
这是我拥有的asp:
<%
'Name of finished file
ImageFile = "sampleXML.xml"
'Destination of finsished file
DestFolder = ""
'Download address of file
URL = "http://localhost/MyWeb/sampleXML.xml"
'Wscript.Echo(URL)
Set xml = CreateObject("Microsoft.XMLHTTP")
xml.Open "GET", URL, False
xml.Send
set oStream = createobject("Adodb.Stream")
Const adTypeBinary = 1
Const adSaveCreateOverWrite = 2
Const adSaveCreateNotExist = 1
oStream.type = adTypeBinary
oStream.open
oStream.write xml.responseBody
' Use this form to overwrite a file if it already exists
oStream.savetofile DestFolder & ImageFile, adSaveCreateOverWrite
oStream.close
set oStream = nothing
Set xml = Nothing
%>
和jQuery:
$("#sampleXML").click(function () {
$.post('downloadXML.asp');
});
谢谢