• sql server保存图片


    sql field image

    长度:自定义,1为一个字节,看你要上传多大的照片,长度就给多少。

    file类型的input,转成byte[] 
     HttpPostedFile upFile = filePhoto.PostedFile;
    int fileLength = upFile.ContentLength;
    if (fileLength > 0)
    {
    Byte[] FileByteArray = new Byte[fileLength];
    Stream StreamObject = upFile.InputStream;
    StreamObject.Read(FileByteArray, 0, fileLength);
    model.FPhoto = FileByteArray;
    }

    读取

    View Code
    SqlDataReader dr = xxxx.ExecuteReader(sql) as SqlDataReader;
    if (dr.Read())
    {
    return (byte[])dr[0];

    }

    显示

    View Code
    context.Response.ContentType = "image/jpeg/gif/x-png";
    context.Response.Cache.SetCacheability(HttpCacheability.Public);
    context.Response.BufferOutput = false;
    int personnelId = WRequest.GetInt("id");
    HR.Dao.Personnel.PersonnelDao bll = new Dao.Personnel.PersonnelDao();
    byte[] file = (Byte[])bll.GetUserImage(personnelId); //把图片信息取出来
    context.Response.BinaryWrite(file); 




  • 相关阅读:
    [USACO06NOV]Corn Fields(状压DP)
    关灯问题II (状态压缩 BFS)
    天梯---至多删三个字符(DP)
    天梯
    蓝桥
    天梯
    天梯
    天梯
    天梯
    蓝桥
  • 原文地址:https://www.cnblogs.com/zhoudemo/p/2412756.html
Copyright © 2020-2023  润新知