文件上传的问题
如下jsp
<%@ page contentType= "text/html; charset=gb2312 " language= "java " import= "java.sql.* " errorPage= " "%>
<%@ taglib uri= "http://java.sun.com/jstl/core_rt " prefix= "c "%>
<%@ taglib uri= "http://www.springframework.org/tags " prefix= "spring "%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN " "http://www.w3.org/TR/html4/loose.dtd ">
<html>
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 ">
<title>
无标题文档
</title>
</head>
<body>
<form name= "oraForm " method= "post " action= " "
enctype= "multipart/form-data "/>
<p>
致辞标题:
<input type= "text " name= "title " lenth=200/>
</p>
致辞内容:
<p>
<textarea name= "content " cols= "40 " rows= "20 "> </textarea> </p>
<p>
图片名称:
<input type= "text " name= "image " />
</p>
图片上传:
<input type= "file " name= "file " size= "30 ">
</p>
<p>
<input type= "submit " name= "Submit " value= "添加 ">
</p>
<p>
</p>
</form>
</body>
</html>
如果把表单中的file类型的字段,用
SmartUpload su =new SmartUpload();
su.initialize(pageContext);
su.setMaxFileSize(10000);
su.setTotalMaxFileSize(20000);
su.setAllowedFilesList( "doc,txt ");
su.setDeniedFilesList( "exe,bat,jsp,htm,html,, "); su.upload();
int count=su.save( "/upload ");
out.println(count+ "个文件上传成功! <br/> ");
种方式上传,那么表单中的其他字段怎么保存到数据库中。谢谢!
[解决办法]
可以用smartupload里的函数
[解决办法]
谢谢,用su.getParameter()得到值后是不是把当前的jsp当作mvc里的控制器,如struts的
action ,spring的controller.