zoukankan      html  css  js  c++  java
  • 用网页显示图片的方法

    方法一、显示原图

    using System;

    namespace DtCms.Web.Tools
    {
        public partial class img : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                string gurl = "/UpLoadFiles/20110117/2011011719440778.jpg";
                Response.ContentType = "image/jpg";
                Response.Clear();
                Response.WriteFile(gurl);
            }

        }
    }

    方法二、二进制显示原图

    using System;
    using System.IO;

    namespace DtCms.Web.Tools
    {
        public partial class httpimg : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                string filePath = "图片路径";
                Response.ContentType = "image/jpg";
                FileStream imageStr = new FileStream(filePath, FileMode.Open);
                byte[] imageData = new byte[imageStr.Length];
                imageStr.Read(imageData, 0, (int)imageStr.Length);
                Response.OutputStream.Write(imageData, 0, (int)imageStr.Length);  

            }
        }
    }

  • 相关阅读:
    web标准化布局
    最全前端资源汇集
    SVN使用教程
    FullPage.js中文帮助文档API
    如何选字体(font-family)
    网站禁止复制类型的属性
    Web前端学习方向
    div 命名规范! (野路子出来的好好看看)
    浏览器兼容处理
    JSONP 跨域问题
  • 原文地址:https://www.cnblogs.com/sntetwt/p/2011187.html
Copyright © 2011-2022 走看看