%@ page trimDirectiveWhitespaces="true" %> <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <%@ page import="org.apache.commons.fileupload.*" %> <%@ page import="java.io.BufferedReader" %> <%@ page import="java.io.File" %> <%@ page import="java.io.InputStream" %> <%@ page import="java.io.BufferedOutputStream" %> <%@ page import="java.io.FileOutputStream" %> <%@ page import="java.io.InputStreamReader" %> <%@ page import="java.util.List" %> <%@ page import="java.net.URL" %> <%@ page import="org.crosswire.utils.HTTPUtils" %> <% String requestURI = request.getRequestURI(); int pe = requestURI.lastIndexOf('/', requestURI.length()-2); requestURI = (pe > 0) ? requestURI.substring(0, pe) : ""; URL baseURL = new URL(request.getScheme(), request.getServerName(), request.getServerPort(), requestURI); URL appBaseURL = new URL(request.getScheme(), request.getServerName(), request.getServerPort(), "/community/"); String userID = null; try { DiskFileUpload fu = new DiskFileUpload(); // maximum size before a FileUploadException will be thrown fu.setSizeMax(99000000); // maximum size that will be stored in memory fu.setSizeThreshold(4096); // the location for saving data that is larger than getSizeThreshold() fu.setRepositoryPath(session.getServletContext().getRealPath("tmp/")); List fileItems = fu.parseRequest(request); for (int i = 0; i < fileItems.size(); i++) { FileItem fi = (FileItem)fileItems.get(i); if (fi.isFormField()) { if ("userID".equals(fi.getFieldName())) { userID = fi.getString(); } } else { byte xml[] = fi.get(); String sqlPath = request.getRealPath("vmr/api/projects/ntconjectures/admin/sql/scripts/"+fi.getName()); FileOutputStream fo = new FileOutputStream(sqlPath, false); fo.write(xml); %> Upload Successful. Files <% return; } } } catch (Exception e) { e.printStackTrace(); } %>