将图片插入到数据库中代码
如何将图片插入到数据库中

试验十数据库编程1、新建项目项目名称为“d bgl”。
2、设计如下窗体:窗体上放置的控件有:7个按钮,一个groupBox,4个label,4个textBox,1个pictureBo x和1个d ataGr idVie w。
3、编写连接数据库的类鼠标单击菜单栏上的“项目”选择“项目”菜单中的“添加类”命令,为“dbgl”项目添加连接数据库的类,类名是:DbConn ectio n。
如下图所示:DbConn ectio n类的代码如下图所示:注意需要引入Sy ste m.Data.SqlCli ent名称空间。
4、编写操作数据的类为“dbgl”项目添加操作数据的类,该类名为“DbOper ation”。
首先,实例化“DbConn ectio n”类,代码如下:其次,编写方法ge tdata set,该方法返回一个DataSet对象的数据集。
代码如下:接着编写执行SQL语句的方法“sqlcmd”。
该方法的代码如下:最后编写方法“GetTab le”,该方法用于返回一个Da taTab le类型的数据。
代码如下:5、为窗体编写代码,完成对数据库操作的功能。
在窗体的代码视图中:(1)定义一个窗体级别的Bi nding Manag erBas e类变量m ybind用来管理多个控件绑定到一个数据源,以便实现同步操作。
代码如下:(2)在窗体的Lo ad事件中编写,为相关控件绑定相数据。
代码如下:(3)为“第一条”按钮控件编写代码:代码如下图所示:(4)为“下一条”按钮控件编写代码:代码如下图所示:(5)为“上一条”按钮控件编写代码:代码如下图所示:(6)为“最后一条”按钮控件编写代码:代码(略)。
自己编写(7)给“新增”按钮编写代码,完成添加一条记录首先,给项目添加一个窗体,窗体名称为“FormBa se”。
C# 图片保存到数据库和从数据库读取图片并显示

C# 图片保存到数据库和从数据库读取图片并显示图片保存到数据库的方法:public void imgToDB(string sql){ //参数sql中要求保存的imge变量名称为@images//调用方法如:imgToDB("update UserPhoto set Photo=@images where UserNo='" + temp + "'");FileStream fs = File.OpenRead(t_photo.Text);byte[] imageb = new byte[fs.Length];fs.Read(imageb, 0, imageb.Length);fs.Close();SqlCommand com3 = new SqlCommand (sql,con);com3.Parameters.Add("@images", SqlDbType.Image).Value = imageb;if (com3.Connection.State == ConnectionState.Closed)com3.Connection.Open();try{com3.ExecuteNonQuery();}catch{ }finally{ com3.Connection.Close(); }}数据库中读出图片并显示在picturebox中:方法一:private void ShowImage(string sql){//调用方法如:ShowImage("select Photo from UserPhoto where UserNo='" + userno +"'");SqlCommand cmd = new SqlCommand(sql, conn);conn.Open();byte[] b= (byte[])cmd.ExecuteScalar();if (b.Length 〉0){MemoryStream stream = new MemoryStream(b, true);stream.Write(b, 0, b.Length);pictureBox1.Image = new Bitmap(stream);stream.Close();}conn.Close();}方法二:当在dg中选中某行时:private void dg_MouseUp(object sender, MouseEventArgs e){//整行选择if (e.Button == System.Windows.Forms.MouseButtons.Left){//用户编号,姓名,性别,身份证号,籍贯,学院,系所,校区,部门,电话,照片//显示相片object imgobj=dg[10, dg.CurrentRow.Index].Value;if (imgobj != null && !Convert.IsDBNull(imgobj)){byte[] imgb = (byte[])imgobj;MemoryStream memStream = new MemoryStream(imgb);try{Bitmap myimge = new Bitmap(memStream);this.pictureBox1.Image = myimge;}catch{DB.msgbox("从数据库读取相片失败!");}}elsepictureBox1.Image = null;}}。
PHP上传图片到数据库并显示的实例代码

PHP上传图⽚到数据库并显⽰的实例代码PHP上传图⽚到数据库并显⽰1、创建数据表CREATE TABLE ccs_image (id int(4) unsigned NOT NULL auto_increment,description varchar(250) default NULL,bin_data longblob,filename varchar(50) default NULL,filesize varchar(50) default NULL,filetype varchar(50) default NULL,PRIMARY KEY (id))engine=myisam DEFAULT charset=utf82、⽤于上传图⽚到服务器的页⾯ upimage.html<!doctype html><html><head><meta charset="UTF-8"><meta name="viewport"content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"><meta http-equiv="X-UA-Compatible" content="ie=edge"><style type="text/css">*{margin: 1%}</style><title>Document</title></head><body><form method="post" action="upimage.php" enctype="multipart/form-data">描述:<input type="text" name="form_description" size="40"><input type="hidden" name="MAX_FILE_SIZE" value="1000000"> <br>上传⽂件到数据库:<input type="file" name="form_data" size="40"><br><input type="submit" name="submit" value="submit"></form></body></html>3、处理图⽚上传的php upimage.php<?phpif (isset($_POST['submit'])) {$form_description = $_POST['form_description'];$form_data_name = $_FILES['form_data']['name'];$form_data_size = $_FILES['form_data']['size'];$form_data_type = $_FILES['form_data']['type'];$form_data = $_FILES['form_data']['tmp_name'];$dsn = 'mysql:dbname=test;host=localhost';$pdo = new PDO($dsn, 'root', 'root');$data = addslashes(fread(fopen($form_data, "r"), filesize($form_data)));//echo "mysqlPicture=".$data;$result = $pdo->query("INSERT INTO ccs_image (description,bin_data,filename,filesize,filetype) VALUES ('$form_description','$data','$form_data_name','$form_data_size','$form_data_type')"); if ($result) {echo "图⽚已存储到数据库";} else {echo "请求失败,请重试";注:图⽚是以⼆进制blob形式存进数据库的,像这样4、显⽰图⽚的php getimage.php<?php$id =2;// $_GET['id']; 为简洁,直接将id写上了,正常应该是通过⽤户填⼊的id获取的$dsn ='mysql:dbname=test;host=localhost';$pdo = new PDO($dsn,'root','root');$query = "select bin_data,filetype from ccs_image where id=2";$result = $pdo->query($query);$result = $result->fetchAll(2);// var_dump($result);$data = $result[0]['bin_data'];$type = $result[0]['filetype'];Header( "Content-type: $type");echo $data;5、到浏览器查看已经上传的图⽚,看是否可以显⽰以上就是本次介绍的全部相关知识点,感谢⼤家的学习和对的⽀持。
php上传图片的代码并保存到数据库

php上传图⽚的代码并保存到数据库connet.php数据库⽂件<?phpmysql_connect("localhost","root",123)or die("sorry");mysql_select_db("db_user");mysql_query("set names utf8");>do_photo.php⽂件<?php//上传你的头像session_start();if(isset($_POST['update'])){include("connect.php");//限制上传照⽚的类型function photo_type($photo_file){//查找"."第⼀次出现的位置//strrpos() 函数查找字符串在另⼀个字符串中最后⼀次出现的位置。
如果成功,则返回位置,否则返回 false。
$position=strrpos($photo_file,".");//如果返回不是false//substr() ⽅法可在字符串中抽取从 start 下标开始的指定数⽬的字符。
//global $suffix;$suffix=substr($photo_file,$position+1,strlen($photo_file)-$position);return $suffix;//定义图⽚上传的⽬录名称//diretory(upload file)}//$photo_name=$_FILES['myform']['name'];$ext=photo_type($_FILES['myform']['name']);//strtolower()转换⼩写 strtoupper()转换⼤写//$ext=strtolower($ext);$upload_dir='./upload/';if($suffix!="jpg" && $suffix!="gif"){die("不⽀持这个类型的图⽚");}//转移到./upload///mova_uploaded_file()$uploadfile=$upload_dir.time().".".$suffix;if(move_uploaded_file($_FILES['myform']['tmp_name'],$uploadfile)){$sql1="update yonjian set photo='{$uploadfile}' where id='{$_SESSION['id']}'";if(mysql_query($sql1)){header("location:account.php");}}}><form name="ljklj" action="do_photo.php" method="post" enctype="multipart/form-data"> <input type="hidden" name="MAX_FILE_SIZE" value="2000000">⽂件<input name="myform" type="file" value="浏览" ><input type="submit" name="update" value="update"></form>请诸位⾼⼿多给建议,我在此多谢数据库为/*Navicat MySQL Data TransferSource Server : jiangSource Server Version : 50155Source Host : localhost:3306Source Database : db_userTarget Server Type : MYSQLTarget Server Version : 50155File Encoding : 65001Date: 2011-11-09 22:12:56*/SET FOREIGN_KEY_CHECKS=0;-- ------------------------------ Table structure for `photo`-- ----------------------------DROP TABLE IF EXISTS `photo`;CREATE TABLE `photo` (`id` int(11) NOT NULL AUTO_INCREMENT,`username` varchar(50) DEFAULT NULL,`photo` varchar(300) DEFAULT NULL,PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=gbk;-- ------------------------------ Records of photo-- ----------------------------。
存储过程_将图片存入数据库

一、写一个存储过程,将图片存入数据库中基本情况介绍:数据库版本:oracle 11g数据库用户:scott数据库密码:tigerJDK:1.6要导入的图片:D:\picture\1.jpg--创建存储图片的表CREATE TABLE IMAGE_LOB (T_ID V ARCHAR2 (5) NOT NULL,T_IMAGE BLOB NOT NULL);--创建存储图片的目录CREATE OR REPLACE DIRECTORY IMAGES AS 'D:\picture';存储过程如下:CREATE OR REPLACE PROCEDURE IMG_INSERT (TID V ARCHAR2,FILENAME V ARCHAR2) ASF_LOB BFILE;--文件类型B_LOB BLOB;BEGINiNSERT INTO IMAGE_LOB (T_ID, T_IMAGE)V ALUES (TID,EMPTY_BLOB ()) RETURN T_IMAGE INTO B_LOB;--插入空的blobF_LOB:= BFILENAME ('IMAGES', FILENAME);--获取指定目录下的文件DBMS_LOB.FILEOPEN(F_LOB, DBMS_LOB.FILE_READONL Y);--以只读的方式打开文件DBMS_LOB.LOADFROMFILE (B_LOB, F_LOB,DBMS_LOB.GETLENGTH (F_LOB));--传递对象DBMS_LOB.FILECLOSE (F_LOB);--关闭原始文件COMMIT;END;--将该图片存入表call IMG_INSERT('1','1.gif'); 验证一下是否已存入:二、从数据库读取图片并显示在页面上项目名称为ShowPhoto启动Tomcat,在浏览器输入:http://localhost:8080/ShowPhoto/,显示如下:。
图片如何存入数据库

图⽚如何存⼊数据库通常对⽤户上传的图⽚需要保存到数据库中。
解决⽅法⼀般有两种:⼀种是将图⽚保存的路径存储到数据库;另⼀种是将图⽚以⼆进制数据流的形式直接写⼊数据库字段中。
以下为具体⽅法: ⼀、保存图⽚的上传路径到数据库: string uppath="";//⽤于保存图⽚上传路径 //获取上传图⽚的⽂件名 string fileFullname = this.FileUpload1.FileName; //获取图⽚上传的时间,以时间作为图⽚的名字可以防⽌图⽚重名 string dataName = DateTime.Now.ToString("yyyyMMddhhmmss"); //获取图⽚的⽂件名(不含扩展名) string fileName = fileFullname.Substring(stIndexOf("\\") + 1); //获取 string type = fileFullname.Substring(stIndexOf(".") + 1); //判断是否为要求的格式 if (type == "bmp" || type == "jpg" || type == "jpeg" || type == "gif" || type == "JPG" || type == "JPEG" || type == "BMP" || type == "GIF") { //将图⽚上传到指定路径的⽂件夹 this.FileUpload1.SaveAs(Server.MapPath("~/upload") + "\\" + dataName + "." + type); //将路径保存到变量,将该变量的值保存到数据库相应字段即可 uppath = "~/upload/" + dataName + "." + type; } ⼆、将图⽚以⼆进制数据流直接保存到数据库: 引⽤如下: using System.Drawing; using System.IO; using System.Data.SqlClient; 设计数据库时,表中相应的字段类型为iamge 保存: //图⽚路径 string strPath = this.FileUpload1.PostedFile.FileName.ToString (); //读取图⽚ FileStream fs = new System.IO.FileStream(strPath, FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(fs); byte[] photo = br.ReadBytes((int)fs.Length); br.Close(); fs.Close(); //存⼊ SqlConnection myConn = new SqlConnection("Data Source=.;Initial Catalog=stumanage;User ID=sa;Password=123"); string strComm = " INSERT INTO stuInfo(stuid,stuimage) VALUES(107,@photoBinary )";//操作数据库语句根据需要修改 SqlCommand myComm = new SqlCommand(strComm, myConn); myComm.Parameters.Add("@photoBinary", SqlDbType.Binary, photo.Length); myComm.Parameters["@photoBinary"].Value = photo; myConn.Open(); if (myComm.ExecuteNonQuery() > 0) { bel1.Text = "ok"; } myConn.Close(); 读取: ...连接数据库字符串省略 mycon.Open(); SqlCommand command = new SqlCommand("select stuimage from stuInfo where stuid=107", mycon);//查询语句根据需要修改 byte[] image = (byte[])command.ExecuteScalar (); //指定从数据库读取出来的图⽚的保存路径及名字 string strPath = "~/Upload/zhangsan.JPG"; string strPhotoPath = Server.MapPath(strPath); //按上⾯的路径与名字保存图⽚⽂件 BinaryWriter bw = new BinaryWriter(File.Open(strPhotoPath,FileMode.OpenOrCreate)); bw.Write(image); bw.Close(); //显⽰图⽚ this.Image1.ImageUrl = strPath; 采⽤俩种⽅式可以根据实际需求灵活选择。
关于数据库插入图片的代码

一、在程序中最好先初始化一张图片备用public void NonePhoto(){FileStream fs = new FileStream(Application.StartupPath + "\\未命名-1.jpg", FileMode.Open, FileAccess.Read);buffByte = new byte[fs.Length];fs.Read(buffByte, 0, (int)fs.Length);fs.Close();fs = null;}然后选择图片的代码public void PhotoBye(){string pathName;if (openFileDialog1.ShowDialog() == DialogResult.OK){pathName = openFileDialog1.FileName;Image im = Image.FromFile(pathName);pbxPhoto.Image = im;FileStream fs = new FileStream(pathName, FileMode.Open, FileAccess.Read);buffByte = new byte[fs.Length];fs.Read(buffByte, 0, (int)fs.Length);fs.Close();fs = null;}}然后插入数据库insertStr += "stuname,stusex,sturace,telephone,";insertStr += "photo,classnumber,depno,postalocde,";insertStr += "role,address,enrolmenttime,classid) values('{0}'";insertStr +=",'{1}','{2}','{3}','{4}',@photo,'{5}','{6}','{7}','{8}','{9}','{10}','{11}')";string sqlSrt = string.Format(insertStr, textBox1.Text, txtName.Text, cbxSex.Text, txtRace.Text, txtPhone.Text, CN, DN, txtDakNo.Text, cbxPolitics.Text, txtAddress.Text, dtpEnrollmentTime.Value.Date, CID);insertDate(sqlSrt);—————————————————————————————————————————public void insertDate(string insertSql){SqlConnection conn = BaseClass.databaseconn.dbconnection();conn.Open();try{SqlCommand insertCmd = new SqlCommand(insertSql, conn);★ insertCmd.Parameters.Add("@photo", SqlDbType.Image);★ insertCmd.Parameters["@photo"].Value = buffByte;int i = insertCmd.ExecuteNonQuery();if (i > 0){MessageBox.Show("添加学生成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);}}二、public void showPhoto(){SqlConnection conn = BaseClass.databaseconn.dbconnection();conn.Open();try{SqlCommand cmd = new SqlCommand("select photo from tb_stuinfo where stuno='" + stuNumber + "'", conn);photoByte = cmd.ExecuteScalar() as byte[];if (photoByte != null){MemoryStream ms = new MemoryStream(photoByte);Bitmap bmp = new Bitmap(ms);this.pictureBox1.Image = bmp;}}。
asp下轻松实现将上传图片到数据库的代码

asp下轻松实现将上传图⽚到数据库的代码轻松实现将上传图⽚到数据库很久就想⾃⼰写⼀写程序了,不过由于赖就不想写我,今天刚好有空,所以写了这个⼩⼩的程序很容易⼀看就知道的,不多说了就此开始: 我们做⼀个上传的。
数据据库的字段就id⾃动编号 big 字段类型是 OLE 呵呵就简单的那个字段好了 uppic.asp上传程序名 <% dim rs dim formsize,formdata,bncrlf,divider,datastart,dataend,mydata formsize=request.totalbytes '取得客户端发过来的⼤⼩ formdata=request.binaryread(formsize)'把客户发过来的数据转成⼆进制作 bncrlf=chrB(13) & chrB(10) divider=leftB(formdata,clng(instrb(formdata,bncrlf))-1) datastart=instrb(formdata,bncrlf & bncrlf)+4 dataend=instrb(datastart+1,formdata,divider)-datastart mydata=midb(formdata,datastart,dataend)'上⾯总共是取得图⽚的⼆进制数据 %> <!--#include file="conn.asp"--> <% sql="select * from pic order by id desc" Set rs = Server.CreateObject("ADODB.Recordset") rs.Open sql,conn,3,2 rs.addnew rs("big").appendchunk mydata '增加到数据库中 rs.update set rs=nothing set conn=nothing %> 接下来是显⽰图⽚ display.asp <!--#include file="conn.asp"--> '这个⼤家都知道吧,他就是与数据库连的⼀个程序了 <% id=request("id") set rs=server.createobject("ADODB.recordset") sql="select * from pic where id=" & id rs.open sql,conn,1,1 Response.ContentType = "text/html" '显⽰图⽚的格式也可以⽤ 'Response.ContentType = "image/gif" 以gif显⽰ 'Response.ContentType = "image/jpg" 以jpg显⽰ Response.BinaryWrite rs("big") '显⽰图⽚ rs.close set rs=nothing set connGraph=nothing %>。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
详解图片上传到数据库2011-04-19 10:32 冯东博客园我要评论(0)字号:T | T数据库中的储存内容不是单单的数据,内容也是丰富多彩的,如今数据库可以实现将图片上传到数据库,下文中就为大家详细介绍将图片上传到数据库的知识。
AD:下面我来汇总一下如何将图片保存到SqlServer、Oracle、Access数据库中,下文内容供大家参考学习,希望对大家能够有所帮助。
首先,我们要明白图片是以二进制的形式保存在数据库中的,那么把图片保存到数据库中的步骤大体上有这几步1.将图片转换为二进制数组(byte[]);2.把转换后的二进制数组(byte[])作为参数传递给要执行的Command;3.执行Command;首先,如何把图片转换成byte[],如果你使用的是2.0,那么你可以使用FileUpLoad控件来实现byte[] fileData = this.FileUpload1.FileBytes;如果你用的是1.1或者你在创建WinForm那么你可以使用下面的方法来把图片转换为byte[]1.public byte[] getBytes(string filePath)2.{3.System.IO.FileStream fs = new System.IO.FileStream(filePath, System.IO.FileMode.Open);4.byte[] imgData = new byte[fs.Length];5.fs.Read(imgData, 0, (int)fs.Length);6.return imgData;7.}8.接下来我们要做的就是要把已经得到的byte[]作为参数传递给Command对象1.SqlServer数据库。
SqlServer有Image字段类型,最大可以存储2G的数据。
byte[] fileData = this.FileUpload1.FileBytes;1.string sql = "insert into t_img(img) values (@img)";2.string strconn = System.Configuration.ConfigurationManager.ConnectionStrings["fengdongDB"].ToString();3.SqlConnection sqlConn = new SqlConnection(strconn);4.SqlCommand sqlComm = new SqlCommand(sql, sqlConn);5.sqlComm.Parameters.Add("@img", SqlDbType.Image);//添加参数6.sqlComm.Parameters["@img"].Value = fileData;//为参数赋值7.8.sqlConn.Open();9.sqlComm.ExecuteNonQuery();10.sqlConn.Close();11.2.Oracle数据库。
在Oracle数据库中我们可以使用BLOB字段类型,最大可以存储4G的数据。
1.byte[] fileData = this.FileUpload1.FileBytes;2.3.string sql = "insert into t_img(imgid,IMGDATA) values(100,:IMGDATA)";4.string strconn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionStringForOracle"].ToString();5.OracleConnection oraConn = new OracleConnection(strconn);6.OracleCommand oraComm = new OracleCommand(sql, oraConn);7.oraComm.Parameters.Add(":IMGDATA", OracleType.Blob);//添加参数8.oraComm.Parameters[":IMGDATA"].Value = fileData;//为参数赋值9.10.oraConn.Open();11.oraComm.ExecuteNonQuery();12.oraConn.Close();13.注意:这里我需要说明一下,用Oracle的专用连接传递参数的时候你要小心一点,看看上面的SQL语句你就会知道,要在参数名前加个“:”否则就会出现下面的错误“OracleException: ORA-01036: 非法的变量名/编号”。
这里需要我们注意一下。
另外还有一个地方,当我引用System.Data.OracleClient命名空间的时候默认是没有的,必须添加对System.Data.OracleClient的引用,我记得在VS2003下如果安装了OracleClient是不用添加引用就可以引入的。
这里也要留意一下。
3.Access数据库。
在Access中我们使用OLE对象字段类型,最大支持1G的数据。
1.byte[] fileData = this.FileUpload1.FileBytes;2.3.string sql = "insert into t_img(IMGDATA) values(?)";4.string strconn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionStringForAccess"].ToString();5.6.OleDbConnection oleConn = new OleDbConnection(strconn);7.OleDbCommand oleComm = new OleDbCommand(sql, oleConn);8.oleComm.Parameters.Add("imgdata", OleDbType.Binary);9.oleComm.Parameters["imgdata"].Value = fileData;10.11.oleConn.Open();12.oleComm.ExecuteNonQuery();13.oleConn.Close();14.好了,到这里我们就把图片保存到数据库中全部说完了,接下来要说的是如何从数据库中把图片读取出来。
实际上这是与插入操做相反的一个过程:先报把从数据库中获取的图片数据转换为数组,然后把数组转换为图片。
不同数据之间没有特别大的差异,我这里只列出从Oracle数据库中把数据读取出来以供参考。
1.private byte[] getImageDataFromOracle()2.{3.string sql = "select IMGDATA from t_img where imgID=100";4.string strconn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionStringForOracle"].ToString();5.OracleConnection oraConn = new OracleConnection(strconn);6.OracleCommand oraComm = new OracleCommand(sql, oraConn);7.8.oraConn.Open();9.byte[] fileData = (byte[])oraComm.ExecuteScalar();10.oraConn.Close();11.12.return fileData;13.}14.我们获取到了数据,那么把byte[]转换为图片的过程都是一样的。
1.private System.Drawing.Image convertByteToImg(byte[] imgData)2.{3.System.IO.MemoryStream ms = new System.IO.MemoryStream(imgData);4.System.Drawing.Image img = System.Drawing.Image.FromStream(ms);5.return img;如果你在开发WinForm应用的话你可以直接把返回结果保存或者显示到PictureBox里,如果你在使用那么你可以在单独的一个页面把图片输出,在另外一个页面把Image控件的ImageUrl属性指向图片输出页面。
比如输出页面getImg.aspx的代码1.protected void Page_Load(object sender, EventArgs e)2.{3.string sql = "select IMGDATA from t_img where imgID=100";4.string strconn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionStringForOracle"].ToString();5.OracleConnection oraConn = new OracleConnection(strconn);6.OracleCommand oraComm = new OracleCommand(sql, oraConn);7.8.oraConn.Open();9.byte[] fileData = (byte[])oraComm.ExecuteScalar();10.oraConn.Close();11.12.System.IO.MemoryStream ms = new System.IO.MemoryStream(fileData);13.System.Drawing.Image img = System.Drawing.Image.FromStream(ms);14.img.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);。