lastBloodySlash = uploadName.lastIndexOf("/"); if(lastBloodySlash>-1){ uploadName = uploadName.substring(lastBloodySlash+1); }
	public String upload(ActionEvent event) throws IOException{				if(uploadFile!=null){			IWContext iwc = IWContext.getInstance();//			Map parameters = ((HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest()).getParameterMap();//			uploadFolderPath = ((String[])parameters.get("uploadForm:uploadPath"))[0];						String tempUploadFolderPath = (String) WFUtil.invoke("WebDAVListBean","getWebDAVPath");			if(tempUploadFolderPath!=null){				uploadFolderPath = tempUploadFolderPath;			}						IWSlideSession session = (IWSlideSession)IBOLookup.getSessionInstance(iwc,IWSlideSession.class);			IWSlideService service = (IWSlideService)IBOLookup.getServiceInstance(iwc,IWSlideService.class);				WebdavRootResource rootResource = session.getWebdavRootResource();			String filePath = service.getWebdavServerURI()+getUploadFilePath();			String uploadName = uploadFile.getName();						//FIXME THIS IS A BUG IN THE MYFACES UPLOADER I THINK			//The problem is that in IE 6 the filename actually contains the full file path!			//example I'm uploading test.txt from c:\myfolder\test.txt to the folder /files/public			//then the variable filePath+fileName = /files/public/C:/myfolder/test.txt			//workaround			int lastBloodySlash = uploadName.lastIndexOf("\\");			if(lastBloodySlash>-1){				uploadName = uploadName.substring(lastBloodySlash+1);			}						lastBloodySlash = uploadName.lastIndexOf("/");			if(lastBloodySlash>-1){				uploadName = uploadName.substring(lastBloodySlash+1);			}				//workaround ends						String fileName = uploadName;						if(!"".equals(name)){				fileName = name;				int lastDot = uploadName.lastIndexOf(".");				if(lastDot>0){					//just add the suffix if it is missing					String suffix = uploadName.substring(lastDot);					if(!fileName.endsWith(suffix)){						fileName+=suffix;					}				}			}					//			boolean createFolderSuccess = rootResource.mkcolMethod(filePath);//			System.out.println("Creating folder success "+createFolderSuccess);						boolean uploadFileSuccess = false;			try {				uploadFileSuccess = rootResource.putMethod(filePath+fileName,uploadFile.getInputStream());			}			catch (HttpException e) {				e.printStackTrace();			}			catch (IOException e) {				e.printStackTrace();			}			System.out.println("Uploading file success "+uploadFileSuccess);												// Always refreshing/keeping status			WFUtil.invoke("WebDAVListBean","refresh", event.getSource(), UIComponent.class);			if(uploadFileSuccess){				String contentType = uploadFile.getContentType();				downloadPath = filePath+fileName;				if(contentType!=null && MimeTypeUtil.getInstance().isImage(contentType)){					imagePath = iwc.getIWMainApplication().getURIFromURL(downloadPath);					}								if(comment!=null && !"".equals(comment)){										rootResource.proppatchMethod(filePath+fileName,new PropertyName("DAV:","comment"),comment,true);									}			}			else{				System.err.println("Error code :"+rootResource.getStatusMessage()+", message: "+rootResource.getStatusMessage());				return "upload_failed";			}				}				return "ok";	}