当前位置: 代码迷 >> ASP.NET >> 在服务器下有个111.doc的文件小弟我上载进想把文件名变成中文《你好.doc》大家有什么好方法推荐一上
  详细解决方案

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

热度:7764   发布时间:2013-02-25 00:00:00.0
在服务器上有个111.doc的文件我下载进想把文件名变成中文《你好.doc》大家有什么好方法推荐一下
..................

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

完整的测试

VBScript code
<%Response.Buffer = trueResponse.ClearDim fso,fl,flsizedim DnameDim objStream,ContentType,flName,isre,url1Dname= Server.Mappath("111.doc")Set fso=Server.CreateObject("Scripting.FileSystemObject")Set fl=fso.getfile(Dname)flsize=fl.sizeSet fl=NothingSet fso=Nothing Set objStream = Server.CreateObject("ADODB.Stream")objStream.OpenobjStream.Type = 1objStream.LoadFromFile DnameContentType = "application/octet-stream"Response.AddHeader "Content-Disposition", "attachment; filename=" & Server.UrlEncode("新名字.doc")Response.AddHeader "Content-Length", flsizeResponse.Charset = "UTF-8"Response.ContentType = ContentTypeResponse.BinaryWrite objStream.ReadResponse.Flushresponse.Clear()objStream.CloseSet objStream = Nothing%>
  相关解决方案