📄 _do__upload.java
字号:
/*@lineinfo:filename=/do_upload.jsp*/
/*@lineinfo:generated-code*/
import oracle.jsp.runtime.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import java.util.*;
import com.jspsmart.upload.*;
import to.model.File.*;
public class _do__upload extends com.orionserver.http.OrionHttpJspPage {
public final String _globalsClassName = null;
// ** Begin Declarations
// ** End Declarations
public void _jspService(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException {
response.setContentType( "text/html; charset=gb2312");
/* set up the intrinsic variables using the pageContext goober:
** session = HttpSession
** application = ServletContext
** out = JspWriter
** page = this
** config = ServletConfig
** all session/app beans declared in globals.jsa
*/
PageContext pageContext = JspFactory.getDefaultFactory().getPageContext( this, request, response, "", true, JspWriter.DEFAULT_BUFFER, true);
// Note: this is not emitted if the session directive == false
HttpSession session = pageContext.getSession();
if (pageContext.getAttribute(OracleJspRuntime.JSP_REQUEST_REDIRECTED, PageContext.REQUEST_SCOPE) != null) {
pageContext.setAttribute(OracleJspRuntime.JSP_PAGE_DONTNOTIFY, "true", PageContext.PAGE_SCOPE);
JspFactory.getDefaultFactory().releasePageContext(pageContext);
return;
}
int __jsp_tag_starteval;
ServletContext application = pageContext.getServletContext();
JspWriter out = pageContext.getOut();
_do__upload page = this;
ServletConfig config = pageContext.getServletConfig();
try {
// global beans
// end global beans
out.write(__oracle_jsp_text[0]);
out.write(__oracle_jsp_text[1]);
/*@lineinfo:user-code*//*@lineinfo:11^1*/ // 新建一个SmartUpload对象 SmartUpload su = new SmartUpload(); // 上传初始化 su.initialize(pageContext); // 设定上传限制 // 1.限制每个上传文件的最大长度。 // su.setMaxFileSize(10000); // 2.限制总上传数据的长度。 // su.setTotalMaxFileSize(20000); // 3.设定允许上传的文件(通过扩展名限制),仅允许doc,txt文件。 // su.setAllowedFilesList("doc,txt"); // 4.设定禁止上传的文件(通过扩展名限制),禁止上传带有exe,bat, //jsp,htm,html扩展名的文件和没有扩展名的文件。 // su.setDeniedFilesList("exe,bat,jsp,htm,html,,"); // 上传文件 su.upload(); // 将上传文件全部保存到指定目录 int count = su.save("/upload"); out.println(count+"个文件上传成功!<br>"); // 利用Request对象获取参数之值 out.println("TEST="+su.getRequest().getParameter("TEST") +"<BR><BR>"); // 逐一提取上传文件信息,同时可保存文件。 for (int i=0;i<su.getFiles().getCount();i++) { com.jspsmart.upload.File file = su.getFiles().getFile(i); // 若文件不存在则继续 if (file.isMissing()) continue; fileItem fi=new fileItem(); FileBean fb=new FileBean(); fi.setWName(file.getFileName()); fi.setWExt(file.getFileExt()); fi.setWSize(String.valueOf (file.getSize())); fi.setWpathName(file.getFilePathName()); fi.setWAddr(file.getFileName()); if(fb.insertFile(fi).equals("上传成功")) { response.sendRedirect("displayFile.jsp"); } else { response.sendRedirect("error.jsp"); } // 显示当前文件信息 out.println("<TABLE BORDER=1>"); out.println("<TR><TD>表单项名(FieldName)</TD><TD>" + file.getFieldName() + "</TD></TR>"); out.println("<TR><TD>文件长度(Size)</TD><TD>" + file.getSize() + "</TD></TR>"); out.println("<TR><TD>文件名(FileName)</TD><TD>" + file.getFileName() + "</TD></TR>"); out.println("<TR><TD>文件扩展名(FileExt)</TD><TD>" + file.getFileExt() + "</TD></TR>"); out.println("<TR><TD>文件全名(FilePathName)</TD><TD>" + file.getFilePathName() + "</TD></TR>"); out.println("<TR><TD>下载地址</TD><TD><a href="+"down.jsp?filepath="+file.getFileName()+">本地下载</a></TD></TR>"); out.println("</TABLE><BR>"); // 将文件另存 // file.saveAs("/upload/" + myFile.getFileName()); // 另存到以WEB应用程序的根目录为文件根目录的目录下 // file.saveAs("/upload/" + myFile.getFileName(), // 另存到操作系统的根目录为文件根目录的目录下 // file.saveAs("c:\\temp\\" + myFile.getFileName(), }
/*@lineinfo:generated-code*/
out.write(__oracle_jsp_text[2]);
}
catch( Throwable e) {
try {
if (out != null) out.clear();
}
catch( Exception clearException) {
}
pageContext.handlePageException( e);
}
finally {
OracleJspRuntime.extraHandlePCFinally(pageContext,false);
JspFactory.getDefaultFactory().releasePageContext(pageContext);
}
}
private static final char __oracle_jsp_text[][]=new char[3][];
static {
try {
__oracle_jsp_text[0] =
"\n".toCharArray();
__oracle_jsp_text[1] =
"\n<html>\n<head>\n<title>文件上传处理页面</title>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=gb2312\">\n</head>\n\n<body>\n".toCharArray();
__oracle_jsp_text[2] =
"\n</body>\n</html>".toCharArray();
}
catch (Throwable th) {
System.err.println(th);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -