关于ASP应用IE8下载文件,文件内容乱码后果

  <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>

  

  

  

  <%

  dim s_fpcnnum ,s_flag,s_fpath,sql,place,s_realpath,s_filename

  s_fpcnnum=Trim(Request.QueryString("n"))

  s_flag=Trim(Request.QueryString("f"))

  s_fpath ="D:/joblogdata/Fpcn/"

  'Response.Write s_fpcnnum '变量n获得的是发票编号

  'Response.Write s_flag '变量f获得的是选择翻开的附件编号 1-6

  'Response.Write s_fpat '文件存储相对门路

  sql ="select s_DeliveryFile,s_ExportItemFile,s_ExportReplyItemFile,s_SignItemFile, s_SignItemReplyFile,s_PackBoxItemFile,s_Addtime from t_Fpcnf where s_DeliveryNum='"&s_fpcnnum&"'"

  '查询各个发票信息

  'Response.Write sql

  set place=conn.execute(sql)

  'place 履行的查询结果

  'Response.Write place("s_ExportItemFile") '如查询出仓单

  If place.eof or place.bof Then

  Response.Write("查询不到附件内容,请联系办理员确认附件可否上传胜利,便可否存在该附件!")

  Else

  'if place("s_ExportItemFile") <> "" then

  'Response.Write place("s_ExportItemFile")

  'end if

  '假设出仓单存在,就打印出来

  Select Case s_Flag

  Case "1" s_filename=place("s_ExportItemFile") '出仓恳求单

  Case "2" s_filename=place("s_ExportReplyItemFile") '出仓单回执

  Case "3" s_filename=place("s_DeliveryFile") '送货单

  Case "4" s_filename=place("s_PackBoxItemFile") '装箱单

  Case "5" s_filename=place("s_SignItemFile") '货色签收单

  Case "6" s_filename=place("s_SignItemReplyFile") '货色签收单回执

  End Select

  s_realpath=s_fpath&Year(place("s_Addtime"))&"/"&GetTimePath(place("s_Addtime"),0)&"/"&s_fpcnnum&"/"&s_filename

  'Response.Write s_realpath

  Dim strchar,fliesend,objectFile,objfile,objStream

  Const loadfilesize=32768 '32KB,也可取其它值,单位:字节

  fliesend=0

  TransferFile=True

  Set objectFile=Server.CreateObject("Scripting.FileSystemObject")

  Set objfile=objectFile.GetFile(s_realpath)

  Set objStream=objfile.OpenAsTextStream(1,-1)

  Response.Clear()

  Response.AddHeader "ContentType","application/octet-stream"

  Response.AddHeader "Content-Disposition","attachment;filename="&s_filename

  Response.AddHeader "content-length",objfile.Size

  Do While Not objStream.AtEndOfStream

  strchar=objStream.Read(1)

  Response.BinaryWrite(strchar)

上一篇:京东云直播基地在重庆正式启动 下一篇:没有了
  • 版权声明:内容来自互联网不代表本站观点,2020-04-02发表于 考试培训栏目。
  • 转载请注明: 关于ASP应用IE8下载文件,文件内容乱码后果| 考试培训 +复制链接