finally, a more sane document upload function.