急。。我为什么总是不能命名上传的文件名

wangkunhong wangkunhong 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
<%
try{
SmartUpload su = new SmartUpload();
su.initialize(pageContext);
su.setMaxFileSize(200000000);
su.setTotalMaxFileSize(20000000);
su.setAllowedFilesList("jpg,gif,bmp,png,ico");
su.setDeniedFilesList("exe,bat,jsp,htm,html,asp,");
su.upload();
for (int i=0;i<su.getFiles().getCount();i++)
{
com.jspsmart.upload.File file = su.getFiles().getFile(i);
if (file.isMissing()) continue;
java.util.Date date = new java.util.Date();
String datetime = new Timestamp(date.getTime()).toString();
String image = date.getTime() + "." +file.getFileExt();
su.save("/myrc/Office/upload/" + image);
String Sql = "update per set image = '"+ image +"' where " +
"regname = '"+session.getAttribute("loginuser")+"'";
stmt.execute(Sql);
stmt.close();
}
response.sendRedirect("JobPhoto.jsp");
}catch (Exception e){
out.println(e.getMessage());
}
%>
su.save("/myrc/Office/upload/");这样就可以上传,但是文件名是原来的。。
su.save("/myrc/Office/upload/" + image);这样就不行了,郁闷啊。。
...全文
评论 9
收藏 已收藏
分享
返回顶部
wangkunhong
Web 开发 81,108 成员 341,721 内容