zoukankan      html  css  js  c++  java
  • 文件下载文件名兼容中英文空格

    //下载
            string filePath = Server.MapPath("../Temp/" + ofname);//路径
            FileInfo fileInfo = new FileInfo(filePath);
            Response.Clear();
            Response.ClearContent();
            Response.ClearHeaders();
            Response.AppendHeader("Content-Disposition", "attachment; filename="" + Server.UrlEncode(ofname) + """);//防止中文名出乱码,不过文件名中的空格会被“+”代替
            Response.AddHeader("Content-Length", fileInfo.Length.ToString());
            Response.AddHeader("Content-Transfer-Encoding", "binary");
            Response.ContentType = "application/octet-stream";
            Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");
            Response.WriteFile(fileInfo.FullName);
            Response.Flush();
            Response.End();

  • 相关阅读:
    启动Docker容器
    Docker 删除容器
    11.18数据库认证
    10.17权限认证
    9.16角色认证
    8.13数据库认证
    6.11Realm简介
    5.8认证流程分析
    4.7固定信息认证
    20张图表达程序员的心酸
  • 原文地址:https://www.cnblogs.com/yubufan/p/3559727.html
Copyright © 2011-2022 走看看