toDataURL's output is base64, how to reduce the uploading time and bandwidth of a factor 1/3?
问题 The goal of the following code is to compress the input file (2 MB JPG file => 500 KB file) and then upload it to server when submitting the <form> . When importing an image from a JPG file into a canvas, and exporting it with toDataURL with: function doit() { var file = document.getElementById('file').files[0], canvas = document.getElementById('canvas'), hidden = document.getElementById('hidden'), ctx = canvas.getContext("2d"), img = document.createElement("img"), reader = new FileReader();