日期:2014-05-17  浏览次数:20363 次

在服务器上有个111.doc的文件我下载进想把文件名变成中文《你好.doc》大家有什么好方法推荐一下
..................

------解决方案--------------------
Response.AddHeader "Content-Disposition", "attachment; filename=" & Server.UrlEncode("新名字.doc")

完整的测试

VBScript code
<%

Response.Buffer = true
Response.Clear

Dim fso,fl,flsize
dim Dname
Dim objStream,ContentType,flName,isre,url1

Dname= Server.Mappath("111.doc")

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


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

ContentType = "application/octet-stream"

Response.AddHeader "Content-Disposition", "attachment; filename=" & Server.UrlEncode("新名字.doc")
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
%>