Note that there are some explanatory texts on larger screens.

plurals
  1. POPOSTing base64 data JavaScript/jQuery
    primarykey
    data
    text
    <p>I am working on a website that allows users to edit photos (in-browser) and then upload them. To edit the images in-browser, I use some JavaScript libraries that work with images in base64. As a result, to POST the image to my server, a simple form with a file input cannot be used. The value of a hidden input is set to a base64 string of the edited image, and that is POSTed. Please see the following, short example.</p> <p><a href="http://pastebin.com/PrfWaS3D" rel="noreferrer">http://pastebin.com/PrfWaS3D</a></p> <p>Obviously, this is very much stripped down, but it does contain the problem I'm running into. In POSTing a 3MB animated GIF, it took 6.5 minutes. During which, my computer was almost completely frozen/unresponsive. (Note: This works <em>perfectly</em> for small images, though)</p> <p>It might be an OS/browser issue, (latest Google Chrome on Ubuntu) but I doubt it. If I put that file input inside the form, and remove base64-ing of data, (i.e. - a standard POSTing of a file) it goes in about one second.</p> <p>Compare 6.5 minutes to 1 second. I have to be doing something wrong. What am I doing wrong here? What should I be doing instead? I'm fairly new to web development, so I'm a little bit in the dark. I am aware that base64 does incur something like a 1.3x size increase, but obviously the upload time here is not scaling with 1.3x. I have done a little bit of console.logging, and </p> <pre><code>var base64 = reader.result; </code></pre> <p>takes about a second. So I do not think that the bottleneck is there. The bottleneck has to be in the uploading. But why? Why is a form file input <em>so</em> much faster than a form hidden input with base64?</p> <p>I apologize for my long winded post, but again, I am new to web development, and don't <em>really</em> understand my problem, so it's hard to be concise while getting all the information across.</p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload