本文主要是介绍用JSP smartupload 上次图片简单实例,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
在网上收集了一些上传的实例
代码如下:
Statement stmt = con.createStatement(ResultSet.TYPE_FORWARD_ONLY ,ResultSet.CONCUR_UPDATABLE); //这个必须!
ResultSet rs = stmt.executeQuery("SELECT * FROM TFILES WHERE ID=1");
// if the resultset is not null
if (rs.next()){
// Initialization
mySmartUpload.initialize(pageContext);
// Upload
mySmartUpload.upload();
// upload file in the DB if this file is not missing
if (!mySmartUpload.getFiles().getFile(0).isMissing()){
try {
rs.updateString("FILENAME",mySmartUpload.getFiles().getFile(0).getFileName());
// Add the current file in the DB field
mySmartUpload.getFiles().getFile(0).fileToField(rs,"FILE");
// Update
rs.updateRow();
count++;
} catch(Exception e) {
out.println("An error occurs : " + e.toString());
}
}
}
// Display the number of files uploaded
out.println(count + " file(s) uploaded in the database.");
rs.close();
stmt.close();
con.close();
这篇关于用JSP smartupload 上次图片简单实例的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!