jupload.jsp

来自「jupload applet 0.63」· JSP 代码 · 共 55 行

JSP
55
字号
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<html>
<head>
</head>
<body >
<%
//
// thanks to markus from the JUpload community forum for this example!
// make sure you switch on JUpload parameter "fixJakartaBug" if you're using fileupload
//

// taken from http://forum.java.sun.com/thread.jsp?thread=433098&forum=45&message=1948251
// makes use of (er, requires) Jakarta's Common's FileUpload project
// avaqilable at http://jakarta.apache.org/commons/fileupload/index.html

org.apache.commons.fileupload.DiskFileUpload fu = new org.apache.commons.fileupload.DiskFileUpload();

// maximum size before a FileUploadException will be thrown
long sizeMax = 1000000;
fu.setSizeMax(sizeMax);

// maximum size that will be stored in memory
int sizeThreshold = 1;
fu.setSizeThreshold(sizeThreshold);

// the location for saving data that is larger than getSizeThreshold()
String path = "/temp";
fu.setRepositoryPath(path);

java.util.List fileItems = fu.parseRequest(request); 

java.util.Iterator it = fileItems.iterator();

if (it.hasNext())
while (it.hasNext())
{
org.apache.commons.fileupload.FileItem fi = (org.apache.commons.fileupload.FileItem) it.next();

// filename on the client
String filename = fi.getName();

out.println("filename = ["+filename+"]<BR>");

// write the file
//fi.write(new java.io.File("/a"));

} // end of WHILE
else
{
 out.println("request had no uploaded files.");
}
%>
</body>
</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?