首页 新闻 赞助 找找看

C#如何将图片转换成二进制数组存在SQL Server数据库里

0
悬赏园豆:50 [已关闭问题] 关闭于 2012-12-27 14:39

这样的页面我想将照片转换成二进制数组上传到数据库里,数据库是image类型 还有一列是varchar类型用来存储照片上传前的类型(如jpg还是其他什么),在读取的时候需要再将数组转换成上传前图片的类型显示,请问 分三层架构要怎么写啊?

W宁宁的主页 W宁宁 | 小虾三级 | 园豆:522
提问于:2012-10-08 11:26
< >
分享
所有回答(3)
0

http://yisean.iteye.com/blog/542687

chenping2008 | 园豆:9836 (大侠五级) | 2012-10-08 13:15
0

用的泛型?

简单的三层吗?

mouu | 园豆:111 (初学一级) | 2012-10-08 13:29

嗯嗯,简单的三层架构,用到EXTJS控件

支持(0) 反对(0) W宁宁 | 园豆:522 (小虾三级) | 2012-10-08 13:31
0

ai......看看我自己做的

public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/plain";
        string id = context.Request.QueryString["picid"];
        if (string.IsNullOrEmpty(id))
        {
            System.IO.FileStream fs = new System.IO.FileStream(System.Web.HttpContext.Current.Server.MapPath("../../icon/20111130160358207106.png"), System.IO.FileMode.Open, System.IO.FileAccess.Read);
            byte[] image = new byte[fs.Length];
            fs.Read(image, 0, image.Length);
            context.Response.ContentType = "png";//设定输出文件类型
            context.Response.OutputStream.Write(image, 0, image.Length);
            context.Response.End();
            return;
        }
        HDQY.HDQYMS.Business.MsHrms.Hrms_worker_zhengzhaoBLL bll = new HDQY.HDQYMS.Business.MsHrms.Hrms_worker_zhengzhaoBLL();
        HDQY.HDQYMS.Entity.HrmsWorkerZhengzhao zhengzhao = bll.GetHrmsWorkerZhengzhaoByID(id);
        if (zhengzhao != null && zhengzhao.Photo != null && zhengzhao.Photo.Length != 0)
        {
            context.Response.ContentType = zhengzhao.PhotoType;//设定输出文件类型
            context.Response.OutputStream.Write(zhengzhao.Photo, 0, zhengzhao.Photo.Length);
            context.Response.End();
        }
        else
        {
            System.IO.FileStream fs = new System.IO.FileStream(System.Web.HttpContext.Current.Server.MapPath("../../icon/20111130160358207106.png"), System.IO.FileMode.Open, System.IO.FileAccess.Read);
            byte[] image = new byte[fs.Length];
            fs.Read(image, 0, image.Length);
            context.Response.ContentType = "png";//设定输出文件类型
            context.Response.OutputStream.Write(image, 0, image.Length);
            context.Response.End();
        }
    }

前台只要向这个页面要数据就行了

W宁宁 | 园豆:522 (小虾三级) | 2012-12-27 14:37
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册