FileStream fs = new FileStream(Server.MapPath("images/DSC_0290.JPG"), FileMode.Open);//将图片文件存在文件流中 long fslength = fs.Length;//流长度 byte[] b1 = new byte[(int)fslength];//定义二进制数组 fs.Read(b1, 0, (int)fslength);//将流中字节写入二进制数组中 fs.Close();//关闭流 //Response.ContentType = "image/jpeg"; //Response.BinaryWrite(b1);//将图片输出在页面 Response.Clear(); Response.ContentType = "image/jpg"; Response.BinaryWrite(b1);
原文地址:https://www.cnblogs.com/cutdragonhit/p/9694813.html
时间: 2024-11-05 16:23:55