Asp实现下载时文件名乱码的问题(GB2312正常,改为UTF-8就乱码)
如题,下载程序文件名为down.asp,该文件保存为ANSI编码时,一切正常,但是保存为UTF-8,并且前面两行做相应修改后,每次点击下载,文件名就变成 乱码,
谁能看出问题在哪?
正常的down.asp(保存为ANSI编码)
<%
filePath="E:\test\11111.rar"
fdisplayName="中文文件名999.rar"
set objFso=server.CreateObject("scripting.filesystemobject")
set fn=objFso.GetFile(filePath)
flsize=fn.size
flname=fn.name
set fn=nothing
set objFso=nothing
set objStream=server.CreateObject("adodb.stream")
objStream.Open
objStream.Type=1
objStream.LoadFromFile filePath
ContentType="appliation/octet-stream"
Response.AddHeader "Content-Disposition", "attachment; filename="&fdisplayName
Response.AddHeader "Content-Length", flsize
Response.ContentType=ContentType
Response.BinaryWrite objStream.Read
Response.Flush
Response.Clear()
objStream.Close
set objStream=nothing
%>
文件名出现乱码的down.asp(保存为UTF-8编码,并且做了红色部分的改动,其他不变)
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%
Response.CharSet="utf-8"
filePath="E:\test\11111.rar"
fdisplayName="中文文件名999.rar"
set objFso=server.CreateObject("scripting.filesystemobject")
set fn=objFso.GetFile(filePath)
flsize=fn.size
flname=fn.name
set fn=nothing
set objFso=nothing
set objStream=server.CreateObject("adodb.stream")
objStream.Open
objStream.Type=1
objStream.LoadFromFile filePath
ContentType="appliation/octet-stream"
Response.AddHeader "Content-Disposition", "attachment; filename="&fdisplayName
Response.AddHeader "Content-Length", flsize
Response.ContentType=ContentType
Response.BinaryWrite objStream.Read
Response.Flush
Response.Clear()
objStream.Close
set objStream=nothing
%>