package com.util;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Vector;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.PageContext;
public class SmartUpload
{
protected byte m_binArray[];
protected HttpServletRequest m_request;
protected HttpServletResponse m_response;
protected ServletContext m_application;
private int m_totalBytes;
private int m_currentIndex;
private int m_startData;
private int m_endData;
private String m_boundary;
private long m_totalMaxFileSize;
private long m_maxFileSize;
private Vector m_deniedFilesList;
private Vector m_allowedFilesList;
private boolean m_denyPhysicalPath;
//private boolean m_forcePhysicalPath;
private String m_contentDisposition;
public static final int SAVE_AUTO = 0;
public static final int SAVE_VIRTUAL = 1;
public static final int SAVE_PHYSICAL = 2;
private SmartFiles m_files;
private SmartRequest m_formRequest;
public SmartUpload()
{
m_totalBytes = 0;
m_currentIndex = 0;
m_startData = 0;
m_endData = 0;
m_boundary = ""; //new String();
m_totalMaxFileSize = 0L;
m_maxFileSize = 0L;
m_deniedFilesList = new Vector();
m_allowedFilesList = new Vector();
m_denyPhysicalPath = false;
//m_forcePhysicalPath = false;
m_contentDisposition = ""; //new String();
m_files = new SmartFiles();
m_formRequest = new SmartRequest();
}
/**
* @deprecated Method init is deprecated
*/
public final void init(ServletConfig servletconfig) throws ServletException
{
m_application = servletconfig.getServletContext();
}
/**
* @deprecated Method service is deprecated
*/
public void service(HttpServletRequest httpservletrequest,HttpServletResponse httpservletresponse) throws ServletException,IOException
{
m_request = httpservletrequest;
m_response = httpservletresponse;
}
public final void initialize(ServletConfig servletconfig,HttpServletRequest httpservletrequest,HttpServletResponse httpservletresponse) throws ServletException
{
m_application = servletconfig.getServletContext();
m_request = httpservletrequest;
m_response = httpservletresponse;
}
public final void initialize(PageContext pagecontext) throws ServletException
{
m_application = pagecontext.getServletContext();
m_request = (HttpServletRequest)pagecontext.getRequest();
m_response = (HttpServletResponse)pagecontext.getResponse();
}
/**
* @deprecated Method initialize is deprecated
*/
public final void initialize(ServletContext servletcontext,HttpSession httpsession,HttpServletRequest httpservletrequest,HttpServletResponse httpservletresponse,JspWriter jspwriter) throws ServletException
{
m_application = servletcontext;
m_request = httpservletrequest;
m_response = httpservletresponse;
}
public void upload() throws ServletException,IOException,SmartUploadException
{
int i = 0;
//boolean flag = false;
boolean flag1 = false;
//boolean flag2 = false;
long l = 0L;
//String s = "";//new String();
//String s2 = "";//new String();
String s4 = ""; //new String();
String s5 = ""; //new String();
String s6 = ""; //new String();
String s7 = ""; //new String();
String s8 = ""; //new String();
String s9 = ""; //new String();
String s10 = ""; //new String();
m_totalBytes = m_request.getContentLength();
m_binArray = new byte[m_totalBytes];
int j;
for(;i < m_totalBytes;i += j)
{
try
{
m_request.getInputStream();
j = m_request.getInputStream().read(m_binArray,i,m_totalBytes - i);
}
catch(Exception exception)
{
throw new SmartUploadException("Unable to upload.");
}
}
for(;!flag1 && m_currentIndex < m_totalBytes;m_currentIndex++)
{
if(m_binArray[m_currentIndex] == 13)
{
flag1 = true;
}
else
{
m_boundary = m_boundary + (char)m_binArray[m_currentIndex];
}
}
if(m_currentIndex == 1)
{
return;
}
for(m_currentIndex++;m_currentIndex < m_totalBytes;m_currentIndex = m_currentIndex + 2)
{
long now=new java.util.Date().getTime();
String s1 = getDataHeader();
m_currentIndex = m_currentIndex + 2;
boolean flag3 = s1.indexOf("filename") > 0;
String s3 = getDataFieldValue(s1,"name");
if(flag3)
{
s6 = getDataFieldValue(s1,"filename");
s4 = now+getFileName(s6);
s5 = getFileExt(s4);
s7 = getContentType(s1);
s8 = getContentDisp(s1);
s9 = getTypeMIME(s7);
s10 = getSubTypeMIME(s7);
}
getDataSection();
if(flag3 && s4.length() > 0)
{
if(m_deniedFilesList.contains(s5))
{
throw new SecurityException("The extension of the file is denied to be uploaded (1015).");
}
if(!m_allowedFilesList.isEmpty() && !m_allowedFilesList.contains(s5))
{
throw new SecurityException("The extension of the file is not allowed to be uploaded (1010).");
}
if(m_maxFileSize > 0L && (long)((m_endData - m_startData) + 1) > m_maxFileSize)
{
throw new SecurityException("Size exceeded for this file : " + s4 + " (1105).");
}
l += (m_endData - m_startData) + 1;
if(m_totalMaxFileSize > 0L && l > m_totalMaxFileSize)
{
throw new SecurityException("Total File Size exceeded (1110).");
}
}
if(flag3)
{
SmartFile file = new SmartFile();
file.setParent(this);
file.setFieldName(s3);
file.setFileName(s4);
file.setFileExt(s5);
file.setFilePathName(s6);
file.setIsMissing(s6.length() == 0);
file.setContentType(s7);
file.setContentDisp(s8);
file.setTypeMIME(s9);
file.setSubTypeMIME(s10);
if(s7.indexOf("application/x-macbinary") > 0)
{
m_startData = m_startData + 128;
}
file.setSize((m_endData - m_startData) + 1);
file.setStartData(m_startData);
file.setEndData(m_endData);
m_files.addFile(file);
}
else
{
String s11 = new String(m_binArray,m_startData,(m_endData - m_startData) + 1);
m_formRequest.putParameter(s3,s11);
}
if((char)m_binArray[m_currentIndex + 1] == '-')
{
break;
}
}
}
p
JAVAWEB校园订餐系统项目源码.zip
需积分: 0 14 浏览量
更新于2023-04-20
收藏 9.97MB ZIP 举报
JAVAWEB校园订餐系统项目源码JAVAWEB校园订餐系统项目源码JAVAWEB校园订餐系统项目源码JAVAWEB校园订餐系统项目源码JAVAWEB校园订餐系统项目源码JAVAWEB校园订餐系统项目源码JAVAWEB校园订餐系统项目源码JAVAWEB校园订餐系统项目源码JAVAWEB校园订餐系统项目源码JAVAWEB校园订餐系统项目源码JAVAWEB校园订餐系统项目源码JAVAWEB校园订餐系统项目源码JAVAWEB校园订餐系统项目源码JAVAWEB校园订餐系统项目源码JAVAWEB校园订餐系统项目源码JAVAWEB校园订餐系统项目源码JAVAWEB校园订餐系统项目源码JAVAWEB校园订餐系统项目源码JAVAWEB校园订餐系统项目源码JAVAWEB校园订餐系统项目源码JAVAWEB校园订餐系统项目源码JAVAWEB校园订餐系统项目源码JAVAWEB校园订餐系统项目源码JAVAWEB校园订餐系统项目源码JAVAWEB校园订餐系统项目源码JAVAWEB校园订餐系统项目源码JAVAWEB校园订餐系统项目源码

码农落落
- 粉丝: 1523
- 资源: 4515
最新资源
- CrxReactors.dll(11.0.0.354)
- CrxReactors.dll(11.1.0.226)
- 【震撼来袭ROS2+CARLA联合仿真,Lattice算法尽在掌控】 解锁智能车新世界,ROS2与CARLA联手打造顶级联合仿真体验告别繁琐安装,一键开启科研与工作的无限可能 亮点一:版本精选,稳
- CrxReactors.dll(11.7.0.5227)
- 3行3列9仓位立体仓库组态王6.55和三菱OPC仿真程序88,带io表接线图cad,带OPC操作步骤视频 ,立体仓库组态王配置与三菱OPC仿真视频教程,立体仓库组态王6.55:三菱OPC仿真程序应用手
- 生成式AI系统中的任务分解与检索增强生成(RAG)设计模式及其实战应用案例
- CrxReactors.dll(11.15.0.13220)
- 基于多二阶广义积分器的谐波提取复现 基于多二阶广义积分器的电网谐波分量提取,可以准确提取电网中的基频负序,5次负序,7次正序,11次负序,13次正序电压幅值,可以根据需求增加更高谐波的提取 默认发2
- CrxReactors.dll(12.0.0.250)
- hpvcp70.dll
- 另类Simulink模型自动化修改方式,能够对模型信号与参数名称的快速自动化调整,自动化脚本能够有效地对 Simulink 模型进行批量处理,例如对模型中的参数,信号进行批量修改,大大提高工程师的工作
- DSP-DLL-18-en.dll
- 基于Astar算法的智能小车路径规划 本模型为MATLA纯代码编写的基于Astar算法的智能小车路径规划 模型有较为详细的注释,同时附参考文献 ,基于Astar算法的MATLAB纯代码智能小车路
- Ccpos.dll(2.4.1.91)
- diagclnt.dll
- 基于机器学习和数字图像处理实现的对仪表盘指针数字的读取