<%@ page contentType="text/html;charset=gbk"%>
<%@ page import="java.sql.*"%>
<%
String path="images/";
// 新建一个smartupload对象
SmartUpload su = new SmartUpload();
// 上传初始化
su.initialize(pageContext);
//设定允许上传的文件(通过扩展名限制),仅允许doc,txt文件。
su.setAllowedFilesList("jpg,png");
//设定禁止上传的文件(通过扩展名限制),禁止上传带有exe,bat,jsp,htm,html扩展名的文件和没有扩展名的文件。
su.setDeniedFilesList("exe,bat,jsp,htm,html");
//上传文件
su.upload();
// 将上传文件全部保存到指定目录
int count = su.save("/images");
out.println(count+"个文件上传成功!
");
// 利用request对象获取参数之值
// 逐一提取上传文件信息,同时可保存文件。
for (int i=0;i<su.getFiles().getCount();i++)
{
com.jspsmart.upload.File file = su.getFiles().getFile(i);
path=path+file.getFileName();
// 若文件不存在则继续
if (file.isMissing()) continue;
}
String mc=su.getRequest().getParameter("tname");
if(mc==null)mc="";
String tt1=su.getRequest().getParameter("ttitle");
if(tt1==null)tt1="";
String sql2="update tb_Ware set Wareprice='"+tt1+"',Wareimage='"+path+"' where Warename ='"+mc+"' ";
boolean x1=zh.executeUpdate(sql2);
if(x1)out.print("ok");
%>