zoukankan      html  css  js  c++  java
  • 文件下载 获取远程图片

               //response.setHeader("Content-disposition","inline; filename=test1.doc"); //线上浏览方式,用IE打开
                response.setHeader("Content-disposition", "attachment; filename=test1.doc");//下载方式,下载,不用浏览器打开
                Response.ContentType = "application/octet-stream";
                Response.AddHeader("Content-disposition", "attachment; filename=ciwong.doc");
                string strDoc = this.RenderView("View", new Examination.Mapping.Entities.Examination() { ExaminationID = id });
                Response.ContentType = "application/ms-doc";
                Response.Write(strDoc);
                Response.Flush();
                Response.End();
                Response.Close();
     //下载远程图片
    public static System.Drawing.Image DownImg(string url) { WebRequest wreq = WebRequest.Create(url); wreq.Timeout = 10000; HttpWebResponse wresp = (HttpWebResponse)wreq.GetResponse(); Stream s = wresp.GetResponseStream(); System.Drawing.Image img = System.Drawing.Image.FromStream(s); img.Save(filename, ImageFormat.Jpeg); img.Dispose(); s.Dispose(); return img; }

               //response.setHeader("Content-disposition","inline; filename=test1.doc"); //线上浏览方式,用IE打开
                response.setHeader("Content-disposition", "attachment; filename=test1.doc");//下载方式,下载,不用浏览器打开
                Response.ContentType = "application/octet-stream";
                Response.AddHeader("Content-disposition", "attachment; filename=ciwong.doc");
                string strDoc = this.RenderView("View", new Examination.Mapping.Entities.Examination() { ExaminationID = id });
                Response.ContentType = "application/ms-doc";
                Response.Write(strDoc);
                Response.Flush();
                Response.End();
                Response.Close();

  • 相关阅读:
    jquery的常用api和两个特性
    react脚手架和深入理解jsx语法
    前端常见的性能优化
    前后端交互模型(一个面试题引发的思考总结)
    jquery源码部分分析
    bootstrap快速上手
    vue总结
    MySQL连接查询驱动表被驱动表以及性能优化
    一分钟掌握MySQL的InnoDB引擎B+树索引
    一分钟明白MySQL聚簇索引和非聚簇索引
  • 原文地址:https://www.cnblogs.com/rhythmK/p/2804847.html
Copyright © 2011-2022 走看看