如题,我将图片存在一个表下。在页面显示的数据中,我多选或者单选的时候,我点击导出图片就会导出存在相应用户ID里的图片,并且重新命名,导出的时候的生成一个文件夹存放这两张图片。有没有会做的大牛,请给详细代码,小弟有思路,但是不会写。谢谢了
图片都是经常访问的资源,有时候还需要对图片做处理,都不放数据库对
string path = Server.MapPath("~/xxxx").TrimEnd('\\') + @"\";//xxxx为你的文件名,转为物理路径
byte[] FileData = new byte[] { 1, 2, 3 };//(byte[])dr["imgdata"];
if (!System.IO.Directory.Exists(path)) System.IO.Directory.CreateDirectory(path);//不存在则创建文件夹
System.IO.FileStream fs = new System.IO.FileStream(path+"xxxxxx.jpg", System.IO.FileMode.Create);//注意xxxxx为你的图片名称
System.IO.BinaryWriter bw = new System.IO.BinaryWriter(fs);
bw.Write(FileData, 0, FileData.Length);
fs.Flush();//数据写入图片文件
fs.Close();