可以将文件上传阿。给你段代码:
我用的是struts做的.
FormFile file = theForm.getTheFile();
................
try {
InputStream stream = null;
FileInputStream fstream = null; stream = file.getInputStream();
System.out.println("------------uploadFileSize is : "+stream.available() +"------------") ; String sql = "update regunion set "+actionpart +"=? where union_id=?";
System.out.println(sql) ; ps = conn.prepareStatement(sql);
ps.setBinaryStream(1,stream,file.getFileSize()) ;
ps.setInt(2, Integer.parseInt(union_Id));
ps.executeUpdate(); System.out .println("passed connection") ;
stream.close();
我用的是struts做的.
FormFile file = theForm.getTheFile();
................
try {
InputStream stream = null;
FileInputStream fstream = null; stream = file.getInputStream();
System.out.println("------------uploadFileSize is : "+stream.available() +"------------") ; String sql = "update regunion set "+actionpart +"=? where union_id=?";
System.out.println(sql) ; ps = conn.prepareStatement(sql);
ps.setBinaryStream(1,stream,file.getFileSize()) ;
ps.setInt(2, Integer.parseInt(union_Id));
ps.executeUpdate(); System.out .println("passed connection") ;
stream.close();
byte b1[]=str.getBytes();
pstm.setByte(1,b1)加到数据库里