jspSmartUpload

//========upload.html===========
<html>
<body bgcolor="while">
<H1>文件上载</H1>
<HR>
<form method="POST" action="upload.jsp" ENCTYPE="multipart/form-data">
<input type="FILE" Name="FILE1" size="50"><BR>
<input type=submit value="upload">
</form>
</body>
</html>

//=========upload.jsp=======
<%@page language="java" import="com.jspsmart.upload.*"%>
<jsp:useBean id="mySmartUpload" scope="page" class="com.jspsmart.upload.SmartUpload"/>
<html>
<body bgcolor="while">
<H1>文件上载</H1>
<HR>
<%
//定义计数变量
int count=0;
//初始化
mySmartUpload.initialize(pageContext);
//设定文件最大上限,这里为100KB
mySmartUpload.setTotalMaxFileSize(1000000);
//调用Bean的实例化对象的方法执行上载操作\r
mySmartUpload.upload();
try{
//在虚拟目录下的upload目录存储文件
//没有虚拟路径就用物理路径,很熟悉的"/upload"
count=mySmartUpload.save("/upload");
//缺省情况下,上载文件同源文件名称相同
//count=mySmartUpload.save("/upload",mySmartUpload.SAVE_VIRTUAL);
//显示已上载的文件数量
out.println(count+"file(s)uploaded.");
}catch (Exception e){
out.println(e.toString());
}
%>
</body>
</html>

你可能感兴趣的:(html,jsp,bean)