HTML Compress File Upload?

2019-01-12 03:29发布

问题:

is there any way you can get a browser to compress a file before uploading it?

ie from an <input type="file">

Thanks, Jamie

回答1:

Not using pure HTTP. You could do it using silverlight or flash, though.



回答2:

Without using Flash, Java, Silverlight, or similar plug-ins, the browser doesn't compress the files it uploads. It's the server that can send compressed data, if it has been set to do so.

To give a complete answer, I should say there are implementations of GZip made in JavaScript; considering that it is made natively in JavaScript, it is not a practical solution, and should be considered only in particular cases.



回答3:

While you can't compress the file before transfer. If the most important thing is that it resides on your server compressed, and is later downloaded compressed. You can easily set up some server side code to do the work after the file is received. As a redundant note, this will do nothing to improve upload speed, as the file is uploaded uncompressed, and then compressed server side.