发布日期:2003-11-27作者:pmwb阅读人次:18002 //========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);//设定文件最大上限,这里为100KBmySmartUpload.setTotalMaxFileSize(1000000);//调用Bean的实例化对象的方法执行上载操作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> 整理发布:独孤求胜 umbrella
转载请注明原文地址: https://ibbs.8miu.com/read-3384.html