
复制<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xml(标准化越来越近了)ns="http://www.w3.org/1999/xhtml"> <head> <metahttp-equiv="Content-Type"content="text/html; charset=gb2312"/> <title>无标题文档</title> </head> <body> <formaction="testblob.jsp(SUN企业级应用的操操作***)"method="post"> <tablewidth="291"border="1"> <tr> <tdwidth="107">id </td> <tdwidth="168"><inputname="id"type="text"/></td> </tr> <tr> <td>file</td> <td><inputname="file"type="file"/></td> </tr> <tr> <td><inputtype="submit"value="提交"/></td> </tr> </table> </form> </body> </html> testblob.jsp(SUN企业级应用的亿华云计算***) <%@ page contentType="text/html;charset=gb2312"%> <%@ page import="java.sql.*" %> <%@ page import="java.util.*"%> <%@ page import="java.text.*"%> <%@ page import="java.io.*"%> <html xml(标准化越来越近了)ns="http://www.w3.org/1999/xhtml"> <head> <metahttp-equiv="Content-Type"content="text/html; charset=gb2312"/> <title>无标题文档</title> </head> <body> <% String id=request.getParameter("id"); String file=request.getParameter("file"); out.print(id); out.print(file); FileInputStream str=new FileInputStream(file); out.print(str.available()); java.sql.Connection conn; java.lang.String strConn; Class.forName("org.gjt.mm.MySQL(和PHP搭配之***组合).Driver").newInstance(); conn= java.sql.DriverManager.getConnection("jdbc:MySQL(和PHP搭配之***组合)://localhost/test","root",""); String sql="insert into test(id,pic) values(?,?)"; PreparedStatement pstmt=conn.prepareStatement(sql); pstmt.setString(1,id); pstmt.setBinaryStream(2,str,str.available()); pstmt.execute(); out.println("Success,You Have Insert an Image Successfully"); pstmt.close(); %> <ahref="readblob.jsp(SUN企业级应用的源码下载***)">查看图片</a> <ahref="postblob.html">返回</a> </body> </html> readblob.jsp(SUN企业级应用的香港云服务器***) <%@ page contentType="text/html;charset=gb2312"%> <%@ page import="java.sql.*, javax.sql.*" %> <%@ page import="java.util.*"%> <%@ page import="java.text.*"%> <%@ page import="java.io.*"%> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xml(标准化越来越近了)ns="http://www.w3.org/1999/xhtml"> <head> <metahttp-equiv="Content-Type"content="text/html; charset=gb2312"/> <title>无标题文档</title> </head> <body> <% java.sql.Connection conn; ResultSet rs=null; Class.forName("org.gjt.mm.MySQL(和PHP搭配之***组合).Driver").newInstance(); conn= java.sql.DriverManager.getConnection("jdbc:MySQL(和PHP搭配之***组合)://localhost/test","root",""); Statement stmt=conn.createStatement(); rs=stmt.executeQuery("select * from test where id=1"); if(rs.next()) { Blob b = rs.getBlob("pic"); int size =(int)b.length(); out.print(size); InputStream in=b.getBinaryStream(); byte[] by= new byte[size]; response.setContentType("image/jpeg"); ServletOutputStream sos = response.getOutputStream(); int bytesRead = 0; while ((bytesRead = in.read(by)) != -1) { sos.write(by, 0, bytesRead); } in.close(); sos.flush(); } %> </body> </html> 1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.31.32.33.34.35.36.37.38.39.40.41.42.43.44.45.46.47.48.49.50.51.52.53.54.55.56.57.58.59.60.61.62.63.64.65.66.67.68.69.70.71.72.73.74.75.76.77.78.79.80.81.82.83.84.85.86.87.88.89.90.91.92.93.94.95.96.97.98.


相关文章
精彩导读
热门资讯
关注我们
