使用samrtupload无法上传100K以上图片

xuehuiwangji 2017-09-08 09:31:58
我使用smartupload上传图片也设置了大小控制,但是我限制的是200K的图片,现在连100K都无法上传,怎么回事?
String path = super.getServletContext().getRealPath("/Images/touxiang"); 
//声明SmartUpload类对象
SmartUpload su = new SmartUpload();

//初始化的方法必须先执行
su.initialize(config,request,response);
try {
su.setAllowedFilesList("jpg");//设置允许上传文件格式(图片)gif,jpg,png
su.setDeniedFilesList("jsp,asp,html,gif,jpeg,png,bmp");//设置禁止上传文件格式
su.setMaxFileSize(210000); //限制每个上传文件的最大长度。
su.upload();
File myfile = su.getFiles().getFile(0);
String ext=su.getFiles().getFile(0).getFileExt();//获取文件后缀
//时间方式命名
String tempname=session.getAttribute("id").toString();
String lastName=tempname +"."+ ext;//完整文件名
myfile.saveAs( path +"/"+ lastName);

Class.forName(className);

conn=DriverManager.getConnection(url,user,password);
Statement stmt= conn.createStatement();

String sql2="select pictouxiang_name from pictouxiang where pictouxiang_employee_ID='"+ session.getAttribute("id").toString() +"'";
ResultSet rs=stmt.executeQuery(sql2);
String onName="";
if(rs.next())
{
onName=rs.getString(1);
}
if (onName=="")
{
String sql="insert into pictouxiang(pictouxiang_employee_ID,pictouxiang_name) values ('"+ session.getAttribute("id").toString() +"','"+ lastName +"')";
st = (Statement) conn.createStatement();// 创建用于执行静态sql语句的Statement对象   
int count = st.executeUpdate(sql);// 执行插入操作的sql语句,并返回插入数据的个数
}
else{
String sql1="update pictouxiang set pictouxiang_name='"+ lastName +"' where pictouxiang_employee_ID='"+ session.getAttribute("id").toString() +"'";
st = (Statement) conn.createStatement();// 创建用于执行静态sql语句的Statement对象   
int count = st.executeUpdate(sql1);// 执行插入操作的sql语句,并返回插入数据的个数
}
conn.close();//关闭数据库连接
out.println("<script>window.alert('上传成功!');window.location.href='Employee_touxiang.jsp';</script>");
}
catch (Exception e){
out.println("<script>window.alert('只允许上传200k以内且为JPG格式的图片');window.location.href='Employee_touxiang.jsp';</script>");
}
...全文
131 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧