Topic: DiskFileUpload找不到??

  Print this page

1.DiskFileUpload找不到?? Copy to clipboard
Posted by: yucc_cau
Posted on: 2005-11-01 11:28

关于文件上传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应该包含了这个类是吧,怎么回事呢

2.Re:DiskFileUpload找不到?? [Re: yucc_cau] Copy to clipboard
Posted by: bluecrystal
Posted on: 2005-11-01 12:49

commons-fileupload package
到apache的网站把这个包下载下来

http://jakarta.apache.org/commons/fileupload/

3.Re:DiskFileUpload找不到?? [Re: yucc_cau] Copy to clipboard
Posted by: yucc_cau
Posted on: 2005-11-01 14:49

tomcat5不是自带了这个包的吗
在winXP下用到时候好像没有另外下这个包就可以的

4.Re:DiskFileUpload找不到?? [Re: yucc_cau] Copy to clipboard
Posted by: bluecrystal
Posted on: 2005-11-01 15:58

应该没有自带把,我看了看tomcat的所有存放库的目录,都没有


   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