Well, for HTML you should use another Web-Server like Lighttpd or Apache.
Trust me, there WILL be many, many security issues if you try to build it on your own, important http daemons (http servers) DO have these issues and are resolving them slowly, update after update (Now, there are very few issues, i'm sure).
Actually, my solution ended up being Lighttpd, so I can help you set it up.
Also, redistributing Client & Server does not mean you are forced to abide by the HTML rules while you build your program.
You could download the programs via a web browser but still they can send fixed-size data.
Or, you could do as most people do:
Organize your packet like this:
1. The first two bytes could store the "packet ID".
Like, "This packet says your nickname is X" or "This packet says you should receive file X, part Y".
2. The next four bytes, in your case, could store the full size of the data.
3. The next four bytes, could store the data in the current packet
4. The next bytes, will contain part of the data
And you send more packets like this.
Or, to make it simpler, you could use RakNet which is free for non-commercial use (And quite easy after getting used to it).