code: private void updateUploadResource(String fieldName, CmsResource upload) {
  
          CmsResource prevUploadResource = m_uploadResourcesByField.get(fieldName);
          if (prevUploadResource != null) {
              try {
                  m_cms.deleteResource(m_cms.getSitePath(prevUploadResource), CmsResource.DELETE_PRESERVE_SIBLINGS);
              } catch (Exception e) {
                  LOG.error("Couldn't delete previous upload resource: " + e.getLocalizedMessage(), e);
              }
          }
          m_uploadResourcesByField.put(fieldName, upload);
      }
docs: Stores the upload resource and deletes previously uploaded resources for the same form field.<p>
  
  @param fieldName the field name
  @param upload the uploaded resource