To extract a file from a download control, you can use this piece of code (its java to convert it to ssjs ..)
// get file from httpservletrequest HttpServletRequest hsr = (HttpServletRequest) FacesContext .getCurrentInstance().getExternalContext().getRequest(); fileUploadID = 'XspFileUpload control'.getClientId(FacesContext.getCurrentInstance()); Map<?, ?> map = hsr.getParameterMap(); UploadedFile f = ((UploadedFile) map.get(fileUploadID)); if (f == null) { throw new java.lang.Exception("File could not be found"); } String fileName = f.getServerFileName() if (super.isValid() && !this.isHidden()) { File serverFile = f.getServerFile(); if (serverFile != null && serverFile.exists()) { String dir = serverFile.getParent(); File tempFile = new File(dir + File.separator + fileName); // create a handle to the file on server } }
jjtbsomhorst
source share