code: private String getTargetFolder(CmsObject cms) throws CmsException {
  
          // get the target folder on the vfs
          CmsResource target = cms.readResource("/", CmsResourceFilter.IGNORE_EXPIRATION);
          if (m_parameterMap.get(I_CmsUploadConstants.UPLOAD_TARGET_FOLDER_FIELD_NAME) != null) {
              String targetFolder = m_parameterMap.get(I_CmsUploadConstants.UPLOAD_TARGET_FOLDER_FIELD_NAME)[0];
              if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(targetFolder)) {
                  if (cms.existsResource(targetFolder)) {
                      CmsResource tmpTarget = cms.readResource(targetFolder, CmsResourceFilter.IGNORE_EXPIRATION);
                      if (tmpTarget.isFolder()) {
                          target = tmpTarget;
                      }
                  }
              }
          }
          String targetFolder = cms.getRequestContext().removeSiteRoot(target.getRootPath());
          if (!targetFolder.endsWith("/")) {
              // add folder separator to currentFolder
              targetFolder += "/";
          }
          return targetFolder;
      }
docs: Returns the target folder for the new resource,
  if the given folder does not exist root folder
  of the current site is returned.<p>
  
  @param cms the CMS context to use
  
  @return the target folder for the new resource
  
  @throws CmsException if something goes wrong