How i upload images using ionic 4 in PWA

Hi i have a ionic develop with and works great in the front end, but i dont know how send this picture to backend.? JSON Objetc? String? base64? how i convert the input file to base64? considering this pwa and cordova doesnt work.


The decision tree looks somewhat like this:

A. Do you control the backend? If not, ask whoever does what format it needs to be in. Done.

B. Are you storing the picture in something that can handle binary data, or only strings with a limited character set? If backend can handle binary, keep going. Otherwise, base64 (either as part of a JSON object or standalone) is probably your best choice.

C. Do you care about the 33% overhead that base64 imposes? If not, go back to B and pretend that the backend can’t do binary.

D. Manage the picture within the Ionic app as an ArrayBuffer, send it in raw binary to the backend, and store it that way. This is the most bandwidth- and storage-efficient plan.

hi, option D, i code it and works great !!! Thanks a lot.

1 Like

Bro I am Ionic Capacitor Developer and I am shifted from Cordova to Capacitor.this small tutorial will help you to browse any image file.this is also able to browse image from browser side without using pwa too.