asp 动态加载节日弹窗,base64转文件流显示图片

Posted 小小枝子

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了asp 动态加载节日弹窗,base64转文件流显示图片相关的知识,希望对你有一定的参考价值。

<% 
    \'动态加载节日弹窗
    dim rsimage,image,displayDate
    set rsimage=server.CreateObject("ADODB.recordset")                  
    image= ""
    ssql1 = "select image,usingdate from OA_IMAGE where usingdate>=\'" & CurrDate & "\' and (delete_flag<>\'*\' or delete_flag is null  )"
    \'Response.Write ssql1
    rsimage.Open ssql1,Conn_oracleIn,1,1
    if not rsimage.EOF then
                   \'image=rsimage("image")
                   \'displayDate=rsimage("usingdate")
                   response.write "<script language=\'javascript\'>javascript:gotourl(\'image.aspx\',\'\',\'\',\'\',\'\',false);</script>"
                %>
            
    <% end if
    rsimage.Close 
    %>


image.aspx
using System;
using System.Collections.Generic;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class image : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            get_photo();
        }
    }

    /// <summary>
    /// 将图片从数据库中读取
    /// </summary>
    public void get_photo()
    {
        string ssql1 = "select image,usingdate from OA_IMAGE where usingdate>=\'" + DateTime.Now.ToString("yyyy-MM-dd") + "\' and (delete_flag<>\'*\' or delete_flag is null  )";
        DataSet ds = DBHelper_Ip.Query(ssql1);
        if (ds.Tables[0].Rows.Count > 0)
        {            
            //将,以前的多余字符串删除
            string base64String = ds.Tables[0].Rows[0]["image"].ToString();
            string strbase64 = base64String.Trim().Substring(base64String.IndexOf(",") + 1);
            byte[] imagebytes = Convert.FromBase64String(strbase64);
            Response.Clear();
            Response.ContentType = "image/png;";
            Response.BinaryWrite(imagebytes);
            Response.Flush();
            Response.End();
        }
    }
}

 

以上是关于asp 动态加载节日弹窗,base64转文件流显示图片的主要内容,如果未能解决你的问题,请参考以下文章

asp.net 图片转成base64位流, 怎么转后在转成图片图片显示不全

将二进制文件转换为Base64字符串

把图片转成base64编码有啥好处吗?

node 图片转base64

Base64码常见操作(url链接文件转base64编码本地文件转base64编码等)

react img 被自动转成base64,无法根据当前路径来动态改变值的解决办法