Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Java SE 综合讨论区  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 DiskFileUpload找不到??
yucc_cau





发贴: 17
积分: 0
于 2005-11-01 11:28 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
关于文件上传Tomcat5.5.9中尽然找不到 DiskFileUpload

*************
<%@ page contentType="text/html;charset=gb2312" language="java" %>

<%@ page import="java.io.*" %>

<%@ page import="java.util.*" %>

<%@ page import="org.apache.commons.fileupload.*" %>

<%

  String saveDirectory = "/home/yucc/share";

String tmpDirectory = "/home/yucc/share";

int maxPostSize = 1024 * 1024 * 1024;

%>

<%

String FileDescription = null;

String FileName = null;

long FileSize = 0;

String ContentType = null;

int count = 0 ;

%>

<%  

DiskFileUpload upload = new DiskFileUpload();



upload.setSizeThreshold(4096);



upload.setSizeMax(maxPostSize);



upload.setRepositoryPath(tmpDirectory);

List /* FileItem */ items = upload.parseRequest(request);

%>

<body>

<%

  Iterator iter = items.iterator();

  

int tmp = 0;

FileItem tmpItem = null;

  while (iter.hasNext())

  {

tmp++;

FileItem item = (FileItem) iter.next();



if (item.isFormField()) {





FileDescription = item.getString();



} else {





FileName = item.getName();

      

  

try {

// for wintel platform

FileName = FileName.substring(FileName.lastIndexOf("\\")+1);

   // for unix-like platform

FileName = FileName.substring(FileName.lastIndexOf("/")+1);

} catch ( Exception ex ) {

  out.println(ex);

}

ContentType = item.getContentType();

FileSize = item.getSize();

tmpItem = item;

}





    if (tmp == 2 && FileSize != 0)

    {

      count ++;

%>

<font color="red">file:<%= count %></font><br>

name<%= FileName %><br>

size<%= FileSize %> Bytes<br>

type<%= ContentType %><br>

describle<%= FileDescription %><br><br>

<%



try {

out.println(FileName);

File uploadedFile = new File(saveDirectory + FileName);

tmpItem.write(uploadedFile);

} catch ( Exception ex ) {

out.println(ex);

}



tmp = 0;

} else if (tmp == 2 && FileSize == 0) {

tmp = 0;

    } // end if

  } // end while

%>

total <font color="red"><%= count %></font>files

</body>

</html>

**********
运行后,提示错误,找不到DiskFileUpload

tomcat5应该包含了这个类是吧,怎么回事呢




话题树型展开
人气 标题 作者 字数 发贴时间
6181 DiskFileUpload找不到?? yucc_cau 2538 2005-11-01 11:28
4707 Re:DiskFileUpload找不到?? bluecrystal 95 2005-11-01 12:49
4535 Re:DiskFileUpload找不到?? yucc_cau 45 2005-11-01 14:49
4723 Re:DiskFileUpload找不到?? bluecrystal 31 2005-11-01 15:58

flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923