这个路径该怎么写?文件能直接下下来

kutakuki 2007-05-24 11:46:40
我的路径在I盘这个映射盘里,找到<%=rs_word("QQNo")%>.pcm这个文件,点击后就自动下载
<a href=file:\\\\I\\<%=rs_word("QQNo")%>.pcm>点这里收听</a>
我每次试都找不到服务器...
那应该怎样写呢?help!!!
...全文
215 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
kutakuki 2007-05-24
  • 打赏
  • 举报
回复
找个路径都没人来解答吗????闷
kutakuki 2007-05-24
  • 打赏
  • 举报
回复
<%
call downloadFile(replace(replace(Request("file"),"\",""),"/",""))

Function downloadFile(strFile)
strFilename = server.MapPath(strFile)

Response.Buffer = True
Response.Clear

Set s = Server.CreateObject("ADODB.Stream")
s.Open
s.Type = 1

on error resume next

Set fso = Server.CreateObject("Scripting.FileSystemObject")
if not fso.FileExists(strFilename) then
Response.Write("<h1>Error:</h1>" & strFilename & " 文件不存在<p>")
Response.End
end if

Set f = fso.GetFile(strFilename)
intFilelength = f.size

s.LoadFromFile(strFilename)
if err then
Response.Write("<h1>Error: </h1> 文件下载错误")
Response.End
end if

Response.AddHeader "Content-Disposition", "attachment; filename=" & f.name
Response.AddHeader "Content-Length", intFilelength
Response.CharSet = "UTF-8"
Response.ContentType = "application/octet-stream"

Response.BinaryWrite s.Read
Response.Flush

s.Close
Set s = Nothing

End Function

%>
这个是我的download
xdspower 2007-05-24
  • 打赏
  • 举报
回复
你的是本地目录啊,如果是网站使用,你必须提供以你的网站地址为标准的URI地址啊。
guoxin 2007-05-24
  • 打赏
  • 举报
回复
关注
kutakuki 2007-05-24
  • 打赏
  • 举报
回复
它需要虚拟目录,如果我要的是在另外一盘的呢?比如我的程序是放在D盘,但是我右键要下载的看的是放在I盘呢?a href=download.asp?file=<%=rs_word("QQNo")%>.pcm  这里怎么写呢?
jobsen123 2007-05-24
  • 打赏
  • 举报
回复
<A href="down.asp?ID=10">down</a>
down.asp
<!--#include file="conn.asp"-->
<%
ID=CLNG(ID)
dim Dname
Dname=cONN.eXECUTE("select downurl from downloads where ID="&ID)(0)
Response.Buffer = true
Response.Clear
dim url
Dim fso,fl,flsize
Dim objStream,ContentType,flName,isre,url1

If Dname<>"" Then
url=server.MapPath("."&"\"&Dname)
'Response.Write Url
End If

Set fso=Server.CreateObject("Scripting.FileSystemObject")
Set fl=fso.getfile(url)
flsize=fl.size
flName=fl.name
Set fl=Nothing
Set fso=Nothing

Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = 1
objStream.LoadFromFile url


Select Case lcase(Right(flName, 4))
Case ".asf"
ContentType = "video/x-ms-asf"
Case ".avi"
ContentType = "video/avi"
Case ".doc"
ContentType = "application/msword"
Case ".zip"
ContentType = "application/zip"
Case ".xls"
ContentType = "application/vnd.ms-Excel"
Case ".gif"
ContentType = "image/gif"
Case ".jpg", "jpeg"
ContentType = "image/jpeg"
Case ".wav"
ContentType = "audio/wav"
Case ".mp3"
ContentType = "audio/mpeg3"
Case ".mpg", "mpeg"
ContentType = "video/mpeg"
Case ".rtf"
ContentType = "application/rtf"
Case ".htm", "html"
ContentType = "text/html"
Case ".txt"
ContentType = "text/plain"
Case Else
ContentType = "application/octet-stream"
End Select


Response.Buffer=True
Response.Clear
Response.AddHeader "Content-Disposition", "attachment; filename=" & flName
Response.AddHeader "Content-Length", flsize

Response.Charset = "UTF-8"
Response.ContentType = ContentType

Response.BinaryWrite objStream.Read
Response.Flush
response.Clear()
objStream.Close
Set objStream = Nothing

%>

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧