以前做上传下载时的代码,供楼主参考吧:上传文件的jsp页面源代码:<%@ page contentType="text/html;charset=gb2312" %><html>
<head>
<title>文件上传处理页面</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body>
<p>&nbsp;</p>
<p align="center">上传文件选择</p>
<FORM METHOD="POST" ACTION="/jsp/pageAction.do?method=saveUploadByFileUpload" ENCTYPE="multipart/form-data">
 <table width="75%" border="1" align="center">
 <tr> 
      <td><div align="center">1、电影,音乐 
          <input type="FILE" name="FILE1" size="30">
        </div></td>
    </tr>
    <tr> 
      <td><div align="center">2、技术资料 
          <input type="FILE" name="FILE2" size="30">
        </div></td>
    </tr>
    <tr> 
      <td><div align="center">3、其他 
          <input type="FILE" name="FILE3" size="30">
          
        </div></td>
    </tr>
    <tr> 
      <td><div align="center">
          <input type="submit" name="Submit" value="上传!">
        </div></td>
    </tr>
    
 </table>
</form>
</body>
</html>
下载文件的jsp页面:<%@ page contentType="text/html;charset=gb2312" %>
<%@ page import="java.net.URLEncoder"%>
<%@ page import="java.util.Random"%>
<%@ page import="com.jspsmart.upload.*" %>
<%@ page import="common.Tools"%>
<%@ page import="java.io.*"%>
<%
 //request.setCharacterEncoding("GB2312");
 //System.out.println( "contentLenth=="+(long)request.getContentLength());
 SmartUpload su = new SmartUpload();
 su.initialize(pageContext);
 String contentLink = Tools.checkNull(request.getParameter("contentLink"));
 //解决文件名中有空格的问题
 contentLink = contentLink.replaceAll("255"," ");
 java.io.File file = new java.io.File(contentLink);
 if(file.isFile())
 {
   Random rd = new Random();
   String desFileName = rd.nextInt(10000)+contentLink.substring(contentLink.lastIndexOf(".")-1);
   //int index = contentLink.lastIndexOf('\\');
   //String desFileName = contentLink.substring(index);
   su.setContentDisposition(null);
   System.out.println("登陆主机为:"+request.getRemoteHost());
   System.out.println("下载文件为:"+contentLink);   //su.downloadFile(contentLink);
   su.downloadFile(contentLink,"attachment",desFileName);
  }
  else if(file.isDirectory())
  {
   String [] fileNames = file.list();
   for(int i=0;i<fileNames.length;i++)
   {
     String fileRealPath = file.getPath()+"\\"+fileNames[i];
     Random rd = new Random();
     String desFileName = rd.nextInt()+fileRealPath.substring(fileRealPath.lastIndexOf(".")-1);
     su.setContentDisposition(null);
     System.out.println(fileRealPath);
     //su.downloadFile(contentLink);
     su.downloadFile(fileRealPath,"attachment",desFileName);
   }
  }%>
上传到服务器的Action里的处理代码(也可以提交到Servlet里):public ActionForward saveUploadByFileUpload(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception
{
try
{
DiskFileUpload fu = new DiskFileUpload();
// 设置允许用户上传文件大小,单位:字节,这里设为2m
fu.setSizeMax(2*1024*1024);
// 设置最多只允许在内存中存储的数据,单位:字节
fu.setSizeThreshold(4096);
// 设置一旦文件大小超过getSizeThreshold()的值时数据存放在硬盘的目录
fu.setRepositoryPath("c:\\windows\\temp");
//开始读取上传信息
List fileItems = fu.parseRequest(request);
// 依次处理每个上传的文件
Iterator iter = fileItems.iterator();
while (iter.hasNext()) 
{
FileItem item = (FileItem)iter.next();
String name = "";
InputStream ins = null;
FileOutputStream ous = null;

//忽略其他不是文件域的所有表单信息
if (!item.isFormField()) 
{
name = item.getName().substring(item.getName().lastIndexOf(File.separator)+1);
long size = item.getSize();
if((name==null||name.equals("")) && size==0)
{
continue;
}
// ins = item.getInputStream();
// ous = new FileOutputStream("H:\\upload\\"+name);
// int len = 0;
// byte [] tmp = new byte[1024];
// while((len=ins.read(tmp))!=-1)
// {
// ous.write(tmp,0,len);
// }
// ous.close();
// ins.close();
item.write(new File("H:\\upload\\" + name));

}
}
}
catch(Exception e)
{
System.out.println("上传文件失败!");
System.out.println(e.getMessage());
}
return mapping.findForward("success");
}