读书人

asp有关问题:上载时怎么更换文件名

发布时间: 2012-08-07 14:54:49 作者: rapoo

asp问题:下载时如何更换文件名
譬如下载链接为 " http://zhidao.baidu.com/aaa.doc "
我希望下载到桌面的是 " 中国.doc "

请高手指点,具体代码最好 3Q

[解决办法]
function download(f,n)
'f文件全路径,n下载文件的文件名
on error resume next
Set S=CreateObject("Adodb.Stream")
S.Mode=3
S.Type=1
S.Open
S.LoadFromFile(f)
if Err.Number>0 then
Response.status="404"
else
Response.ContentType="application/octet-stream"
Response.AddHeader "Content-Disposition:","Attachment;filename="&n
if Range="" then
Response.BinaryWrite(S.Read)
else
S.Postion=Clng(Split(Range,"-")(0))
Response.BinaryWrite(S.Read)
end if
End if
Response.end
end function
if request("Path")<>"" and request("Name")<>"" then
call download(request("Path"),request("Name"))
end if

读书人网 >ASP

热点推荐