使用jspsmartupload的问题 急问

来源:百度知道 编辑:UC知道 时间:2024/05/23 19:45:50
我刚学习使用smartupload上传组件 按着书上编了个测试程序总是出错 我的jar包在tomcat的common/lib和shared/lib下面都放了啊。。
请高人看看我的程序:
提交页面就不写了 就是一个form提交file文件
处理页面:
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.util.*" import="com.jspsmart.upload.*"%>
<html>
<head>
<title>用smartUpload组件实现文件上传</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body>
<div align="center">
<%
SmartUpload su = new SmartUpload();
su.initialize(pageContext);
su.setMaxFileSize(1000000);

su.setTotalMaxFileSize(4000000);

su.setAllowedFilesList("doc,txt");

su.setDeniedFilesList("exe,bat,jsp,htm,html,,");

su.upload();

int count = su.save("/uploadfiles");
out.println(&

最好采用servlet的方式来处理以上jsp内的内容。
问题基本能解决。
补充,只要是上网找的,一般没问题,只不过靠jsp来处理smartupload的可能会失效。
我去网上给你找了一个。你自己看看。

response.setContentType("text/html;charset=gb2312");
PrintWriter out = response.getWriter();
SmartUpload mySmartUpload = new SmartUpload();
String currentDirectoryPath=null;
String savePath="E:/public_html/java_root/NETDISK/WebRoot/NET_SPACE/1/我的音乐/";
//mySmartUpload.setDenyPhysicalPath(true);
mySmartUpload.setForcePhysicalPath(true);
mySmartUpload.initialize(this.getServletConfig(), request,response);
// 设定上传限制
// 1.限制每个上传文件的最大长度。10M
mySmartUpload.setMaxFileSize(10000000);

// 2.限制总上传数据的长度。

// mySmartUpload.setTotalMaxFileSize(20000);

// 3.设定允许上传的文件(通过扩展名限制),仅允许doc,txt文件。