代码:(使用Eclipse for J2EE开发环境)
FileUpload.html
<html>
<head>
<title>File Upload</title>
</head>
<body>
<form name = "form1" method = "post" action = "upload.jsp" enctype = "multipart/form-data">
<input type = "file" name = "file1" size = "50"/><br>
<input type = "submit" value = "submit"/>
</form>
</body>
</html>
upload.jsp:
<%@ page language="java" import = "com.jspsmart.upload.*" contentType="text/html; charset=GBK"%>
<html>
<head>
<title>Upload JSP</title>
</head>
<body>
<%
SmartUpload mySmartUpload = new SmartUpload();
int count = 0;
mySmartUpload.initialize(pageContext);
out.println(pageContext.toString()+"<br>");
mySmartUpload.setTotalMaxFileSize(100000);
mySmartUpload.setAllowedFilesList("doc,txt,jpg");
mySmartUpload.upload();
try {
count = mySmartUpload.save("/upload");
out.println(count+" file(s) upload.");
} catch (Exception e) {
e.printStackTrace();
}
%>
</body>
</html>
tomcat下没有。
追答通过组件传到服务器上的文件里的