I assume WebRTC or similar could handle this. I just googled it and this showed up: https://www.sharedrop.io/
But - in many cases people need to transfer files asynchonously - either because they can't guarantee both machines will be online for the duration of the transfer, or the other person wants to receive the file at some other time other than "now".