As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
public void execute(WebScriptRequest req, WebScriptResponse res) throws IOException { try { HttpServletRequest httpReq = ((WebScriptServletRequest)req).getHttpServletRequest(); FileItemFactory factory = new DiskFileItemFactory(); ServletFileUpload upload = new ServletFileUpload(factory); List items = upload.parseRequest(httpReq); res.getWriter().write("no items: "+items.size()); Iterator iter = items.iterator(); while(iter.hasNext()) { FileItem item = (FileItem)iter.next(); if(item.isFormField()) { res.getWriter().write("\nIs Form Field"); res.getWriter().write("\nField Name: "+item.getFieldName()); } else { res.getWriter().write("\nIs Uploaded File"); res.getWriter().write("\nField Name: "+item.getFieldName()); } } } catch(Exception e) { res.getWriter().write("Error in processing web service\n\n"+ e.getMessage()+"\n\n"+ e.getStackTrace()+"\n\n"+ e.getCause()+"\n\n"+ "error class= "+e.getClass()); } }
The following example allows the user to upload an HTML document for validation:<FORM METHOD=post ACTION="/cgi-bin/validate.cgi" ENCTYPE="multipart/form-data"><P>Select an HTML document to upload and validate. If your browser does not support form-based file upload, use one of our <A HREF="methods.html">alternate methods of validation</A>.</P><P><INPUT TYPE=file NAME="html_file" ACCEPT="text/html"></P><P><INPUT TYPE=submit VALUE="Validate it!"></P></FORM>