Implement the generic upload function.