reimplemented media upload using XMLHTTPRequest instead of raw TCP sockets.
Fixes upload problems on Firefox OS 2.x.
cleaned up code to better match existing download function
Merge pull request #7 from cmeerw/use-xmlhttprequest-for-upload

Use xmlhttprequest for upload