It's not necessary to encode a file to upload it to an HTTP server.

In this script I tried to imitate the way a browser would upload the file, and it appears to work.