modified upload directive to support more use cases