如何把存储在表中一个字段中的照片显示出来?
如何把存储在表中一个字段中的照片显示出来?
在什么地方显示?
如果是在页面上显示的话,给你一段参考代码。
byte[] photo = table.FileContent; //FileContent是保存照片的数据库字段
string strPath = "~/photos/" + table.ID + ".JPG"; //路径
string strPhotoPath = page.Server.MapPath(strPath); //获取绝对路径
BinaryWriter bw = new BinaryWriter(File.Open(strPhotoPath, FileMode.OpenOrCreate)); //获取一个 实例
bw.Write(photo);
bw.Close();
image.ImageUrl = strPath;