<%@ page contentType="text/html; charset=UTF-8" %> <%@ page import="java.io.*" %> <%@ page import="java.util.*" %> <%@ page import="org.apache.commons.fileupload.*" %> Rad Upload Plus <% /* * This is a sample jsp script that demonstrates handling file uploads using * jsp. It is provided free of charge and with no warranty. * In order to make use of this JSP you need to have the commons file upload * library installed. */ int i=0; /* * Use a pathname that the servlet container has write permissions as * your save path. */ String savePath=""; String parentPath=request.getParameter("userfile_parent"); try { System.out.println( "CONTENT-LENGHT" + request.getContentLength()); System.out.println("session id = " + session.getId()); DiskFileUpload fu = new DiskFileUpload(); // maximum size before a FileUploadException will be thrown fu.setSizeMax(5000000); // maximum size that will be stored in memory fu.setSizeThreshold(4096); // the location for saving data that is larger than getSizeThreshold() fu.setRepositoryPath("/tmp"); List fileItems = fu.parseRequest(request); Iterator item = fileItems.iterator(); while(item.hasNext()) { FileItem fi = (FileItem) item.next(); if(fi.isFormField()) { continue; } String[] parts = fi.getName().split("/"); String fileName = parts[parts.length-1]; if(fileName != null && !fileName.equals("")) { if( (i %2)==1) { out.print(""); } else { out.print(""); } out.println(""); i++; if(! savePath.equals("")) { File f = new File(savePath + fileName); System.out.println("f = " + f.getAbsolutePath()); fi.write(f); } } } } catch (Exception ex) { // ex.printStackTrace(); } %>
Files Uploaded
File Name File size
"+ fileName +"" + fi.getSize() +"

 

Sample JSP Upload handler provided by Rad Inks

 

have you seen our Secure FTP Applet or   our Multimedia Messaging Solution?