Uploads working, rewrote a lot of the socket and protocol handling as per some borrowed code from PHP-WebSockets