📄 jupload.jsp
字号:
<%@ 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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -