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();

  • 相关阅读:
    dts--framework(三)
    dts--tests(三)
    dts--tests(一)
    dts--framework(二)
    dts--framework(一)
    Fiddler(一)
    javascript(二)
    javascript(一)
    scrapy--selenium(二)
    linux安装vmware出现kernel-header问题
  • 原文地址:https://www.cnblogs.com/rhythmK/p/2804847.html
Copyright © 2011-2022 走看看