1

I am writing a mobile app with Phonegap. I have to change an image when the user selects a new one from the gallery. Then I send it to the server in base64. The server receives my image correctly and when I ask for it, it gives me the image encoded in base64 format correctly. I've tried to paste the result on an online converter and it returns the correct image.

My problem is: when I receive back the image as a base64 string, I have to set the "src" attribute and I am doing it like this with jQuery:

$('#immagineprova').attr('src', "data:image/png;base64," + result.img);

The result is what I get back from my server request. Everything is working fine in a browser, but when I run my application with "phonegap run android", the image is not displayed.

I tried to copy the value of result.img, ie. what I get back from the server, and paste it in place of result.img and it works. Of course in this way it will always show the same image and I have to show what user selected instead.

How can I fix my issue?

1 Answer 1

0

Try hooking up the Android Remote Debugger and look for errors in the Console tab.

One possibility is a CSP problem - you need to allow images like this to be displayed.

(Also, start thinking about moving away from PhoneGap - the service is being discontinued. Alternatives are Capacitor, VoltBuilder and Monica.)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.