怎么使用ASP 来读取它 并且返回一个文件地址值,要用ASP自己在内部完成。作者: DJ爱有多痛DJ 时间: 2010-1-7 05:31
Function GetUrl()
On Error Resume Next
Dim strTemp
If LCase(Request.ServerVariables("HTTPS")) = "off" Then
strTemp = "http://"
Else
strTemp = "https://"
End If
strTemp = strTemp & Request.ServerVariables("SERVER_NAME")
If Request.ServerVariables("SERVER_PORT") <> 80 Then
strTemp = strTemp & ":" & Request.ServerVariables("SERVER_PORT")
end if
strTemp = strTemp & Request.ServerVariables("URL")
If Trim(Request.QueryString) <> "" Then
strTemp = strTemp & "?" & Trim(Request.QueryString)
end if
GetUrl = strTemp
End Function
Response.Write(GetUrl())作者: Iしovのyou 时间: 2010-1-7 05:32
好的哦 前面的问题好像 没有达到我的目的! 可能是我说错了
http://bbs.bc-cn.net/viewthread.php?tid=143515&star=at#作者: 爱(じΩvê) 时间: 2010-1-7 05:32
上面的可以用了吗?作者: 江边人家 时间: 2010-1-7 05:32
直接说调用下载函数咯。。
download.asp中的带奥妙应该是这样。。
<%
'Filename must be input
Function downloadFile(url)
' make sure you are on the latest MDAC version for this to work
' get full path of specified file
strFilename = server.MapPath(url)
' clear the buffer
Response.Buffer = True
Response.Clear
' create stream
Set s = Server.CreateObject("ADODB.Stream")
s.Open
' Set as binary
s.Type = 1
' load in the file
on error resume next
' check the file exists
Set fso = Server.CreateObject("Scripting.FileSystemObject")
if not fso.FileExists(strFilename) then
Response.Write("<h1>Error:</h1>"&strFilename&" does not exists!<p>")
Response.End
end if
' get length of file
Set f = fso.GetFile(strFilename)
intFilelength = f.size
s.LoadFromFile(strFilename)
if err then
Response.Write("<h1>Error: </h1>Unknown Error!<p>")
Response.End
end if
' send the headers to the users Browse
Response.AddHeader "Content-Disposition","attachment; filename="&f.name
Response.AddHeader "Content-Length",intFilelength
Response.CharSet = "UTF-8"
Response.ContentType = "application/octet-stream"
' output the file to the browser
Response.BinaryWrite s.Read
Response.Flush
' tidy up
s.Close
Set s = Nothing
End Function
%>
<%
'此处的 url 仅为下载文件的名称(包括扩展名)
loadfile = downloadFile(url) '调用文件下载函数
%>作者: 爲眀天活着 时间: 2010-1-7 05:32
晕 我才来论坛 没想到大家回答这么积极,谢谢啊!作者: 怎么可能 时间: 2010-1-7 05:32
那以后要多来啊.