Improve upload support.
Warning: the return value is now different.