public boolean upload() throws ServletException, IOException, SmartUploadException { int i = 0; boolean flag = false; long l = 0L; boolean flag1 = false; 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(); boolean flag2 = false; m_totalBytes = m_request.getContentLength(); if (m_totalBytes > m_maxFileSize) // kong add { return false; } 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 true; for (m_currentIndex++; m_currentIndex < m_totalBytes; m_currentIndex = m_currentIndex + 2) { 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 = 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) { File file = new File(); // upload.File file = new upload.File(); 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; } return true; }