81,092
社区成员
发帖
与我相关
我的任务
分享
String dir = servlet.getServletContext().getRealPath("/upload");
File uploadFile = new File(dir); //指定上传文件的位置
if (!uploadFile.exists() || uploadFile == null) { uploadFile.mkdirs();
}
String path = uploadFile.getPath() + "\\" + fname;
String fileName = subjectPlanForm.getFileName();
String fileDate = DateFormat.getDateInstance().format(date);
String sql =
"insert into tb_plan(title,fileName,filePath,fileDate) values('" +planForm.getTitle()+"','" + fileName + "','" + path + "','" + fileDate +"')";
try{
stmt.executeUpdate(sql);
}catch(SQLException ex){
ex.printStackTrace();
}finally{
stmt.close();
conn.close();
}