‘======img.asp============= '--------------------------------------------------- '检测函数把数据库的值赋给session变量。 Function PicList(F_list, F_type) F_type = LCase(trim(F_type))'如果有问题就屏蔽这一句 nFieldSize =F_list.ActualSize bytes =F_list.GetChunk(nFieldSize) session("Bytes") = bytes session("Type") = F_type End Function '==================================================== %> <% '按照数据流的格式和类型写出Bytes的原内容。 strsql="select * from * where id="&request("id") rs.open strsql,conn piclist rs("picture"),rs("imag") '显示文件的图片格式picture为图片数据imag为图片类别 response.Expires = 0 response.Buffer = True response.Clear response.contentType=session("Type") 'Response.Write(Session("ImageBytes")) response.BinaryWrite session("Bytes") session("Type")="" session("Bytes")="" response.End '==========程序结束=== 在其它的网页上调用<img srg=img.asp?id=<%=*%> name ="pic" >就可以了
wypenguin(WangYong) ,楼主要的是JAVA呀!
直接操作BLOB字段就是了把图片文件直接写入或者先读取byte[],然后写BLOBstrSQL = "insert into inform(FILEATT) values(empty_blob())"; pstmt = conn.prepareStatement(strSQL); pstmt.executeUpdate();
strSQL = "select FILEATT from inform "; rs = pstmt.executeQuery();
if (rs.next()) { oracle.sql.BLOB blob = (oracle.sql.BLOB)rs.getBlob("INFILE_DATA"); BufferedOutputStream out = new BufferedOutputStream(blob.getBinaryOutputStream()); BufferedInputStream in = new BufferedInputStream(file.getInputStream());
int c; while ((c=in.read())!=-1) { out.write(c); } in.close(); out.close(); }
'---------------------------------------------------
'检测函数把数据库的值赋给session变量。
Function PicList(F_list, F_type)
F_type = LCase(trim(F_type))'如果有问题就屏蔽这一句
nFieldSize =F_list.ActualSize
bytes =F_list.GetChunk(nFieldSize)
session("Bytes") = bytes
session("Type") = F_type
End Function
'====================================================
%>
<% '按照数据流的格式和类型写出Bytes的原内容。
strsql="select * from * where id="&request("id")
rs.open strsql,conn
piclist rs("picture"),rs("imag")
'显示文件的图片格式picture为图片数据imag为图片类别
response.Expires = 0
response.Buffer = True
response.Clear
response.contentType=session("Type")
'Response.Write(Session("ImageBytes"))
response.BinaryWrite session("Bytes")
session("Type")=""
session("Bytes")=""
response.End
'==========程序结束===
在其它的网页上调用<img srg=img.asp?id=<%=*%> name ="pic" >就可以了
pstmt = conn.prepareStatement(strSQL);
pstmt.executeUpdate();
strSQL = "select FILEATT from inform ";
rs = pstmt.executeQuery();
if (rs.next()) {
oracle.sql.BLOB blob = (oracle.sql.BLOB)rs.getBlob("INFILE_DATA");
BufferedOutputStream out = new BufferedOutputStream(blob.getBinaryOutputStream());
BufferedInputStream in = new BufferedInputStream(file.getInputStream());
int c;
while ((c=in.read())!=-1) {
out.write(c);
}
in.close();
out.close();
}