Hi there! I'm diving into backend-frontend programming after spending several years with C# and Java. I'm curious about the best method to send image data from a simple HTML and JavaScript client to a Google Apps Script server. I don't need to focus on encryption or anything fancy—just the basics. Should I go with an API call using base64 image data, or are there more efficient ways to encode or decode images for web communication? Would love to hear your thoughts!
3 Answers
The easiest way is to use a standard form input with ``, and let the browser handle the file upload for you. On the server side, just read the file, validate it, and then save it as needed. You can also use an API call, sending the form data in the request body, and the browser takes care of most of that too.
Avoid using base64, as it increases the data size by about a third. Instead, send the image as raw binary data. If you need to attach other data, use multipart form submissions, which is what you get with a simple HTML form. You can also achieve this using JavaScript if needed.
Thanks for the tip!
You could also consider using presigned URLs for S3, or simply doing a standard form data HTTP POST for simplicity.

Just a heads up, there’s a file size limit with that approach, typically around 2MB.