当前位置: 代码迷 >> 综合 >> jspSmartUpload
  详细解决方案

jspSmartUpload

热度:39   发布时间:2023-12-19 00:30:01.0
//========upload.html===========
<html>
<bodybgcolor="while">
<H1>文件上载</H1>
<HR>
<formmethod="POST"action="upload.jsp"ENCTYPE="multipart/form-data">
<inputtype="FILE"Name="FILE1"size="50"><BR>
<inputtype=submitvalue="upload">
</form>
</body>
</html>

//=========upload.jsp=======
<%@pagelanguage="java"import="com.jspsmart.upload.*"%>
<jsp:useBeanid="mySmartUpload"scope="page"class="com.jspsmart.upload.SmartUpload"/>
<html>
<bodybgcolor="while">
<H1>文件上载</H1>
<HR>
<%
//定义计数变量
intcount=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(Exceptione){
out.println(e.toString());
}
%>
</body>
</html>