Gzip compression for HTML form upload?

25 views Asked by At

In a HTML page I have an upload form this like:

<form action="upload" enctype="multipart/form-data" method="POST">
  <input name="convertfile" type="file">
  <input type="submit" value="Upload">
</form>

Is there any way in HTML to specify that the filedata (or the HTTP form content of the POST), should be sent with GZIP content-encoding?

I would like the client to compress the selected file before uploading. Is this something you could only achieve in Javascript?

1

There are 1 answers

0
Éric On

This is done automatically if the client browser and the server support compression and can agree on a common compression algorithm (which is almost always the case nowadays).

From "Compression in HTTP" by MDN Web Docs, 26 Mar. 2024:

[...]
All modern browsers and servers do support it and the only thing to negotiate is the compression algorithm to use. These algorithms are optimized for text. In the 1990s, compression technology was advancing at a rapid pace and numerous successive algorithms have been added to the set of possible choices. Nowadays, only two are relevant: gzip, the most common one, and br the new challenger.
[...]