zoukankan      html  css  js  c++  java
  • asp.net 图片下载

             string fileName = "123.jpg";//图片名字
                        string filePath = Server.MapPath("../upload/123.jpg");//图片路径
           
                        //以字符流的形式下载文件
                        FileStream fs = new FileStream(filePath, FileMode.Open);
                        byte[] bytes = new byte[(int)fs.Length];
                        fs.Read(bytes, 0, bytes.Length);
                        fs.Close();
                        Response.ContentType = "application/octet-stream";
                        //通知浏览器下载文件而不是打开
                        Response.AddHeader("Content-Disposition", "attachment;  filename=" + HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
                        Response.BinaryWrite(bytes);
                        Response.Flush();

    //此处可以加上下载量的计算

             Response.End();

  • 相关阅读:
    Spring+Mybatis+Maven+MySql搭建实例
    Spring+Mybatis+SpringMVC+Maven+MySql搭建实例
    SQL GROUP BY 语句
    SQL SUM() 函数
    SQL MIN() 函数
    SQL MAX() 函数
    SQL LAST() 函数
    SQL FIRST() 函数
    SQL COUNT() 函数
    SQL AVG() 函数
  • 原文地址:https://www.cnblogs.com/dreamzcy/p/3184368.html
Copyright © 2011-2022 走看看