Fix for issue 538

Addresses issue #538 by reimplementing upload using XMLHTTPRequest instead of raw TCP sockets.