Load image in webviewer from imagepicker selection

I'm trying to insert an image taken with image picker by passing it to the html file via a webvievstring, but it doesn't work.

as you can see from the blocks when I initialize the screen I make a simple call to the webviewer with a string of an image found in assets. Everything works fine

but when I load the image with imagepicker and pass it to webviever1 it doesn't work.

in webviewer2 instead I directly pass the imagepicker path and everything works fine.

This is my html simply code:

img..txt (257 Bytes)

What happens if you try like this ?

this is ok,.,but my iussue is with imagepicker selection.
My problem comes out when I send the imagepicker selection to the html file as a webstring

1 Like

WebViewer doesn't have FileAccess property enabled, I guess.

Convert the picked image to a base64 data uri, then pass this to the webviewstring

So I can only load the image using your Custom Webview extension or by writing one from scratch

Yes, this is correct, but I need direct access without using extensions

Copy your html file from the assets to the imagePicker folder and open it from there.

If images are in the same location as the html file then the html file can access them.

which is usually imagePicker folder's path

Is that a question ?

When using companion the imagePicker folder, on Android 13, is here:

ok,thanks,i'll try your solution

This is working for me in companion on Android 13

<!DOCTYPE html>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
	<p id = "p1"></p>
	<img id = "img1">
	if (window.AppInventor) {
		document.getElementById("p1").innerHTML = "image displayed";
	} else {
		document.getElementById("p1").innerHTML = "no image to show";
1 Like

Error file not found

You duplicate most of this:


see my blocks to understand how much of the file path is already present, and what you need to provide

Also, your approach to copy the html file in the afterPicking event may be better, because the imagepicker will always delete the oldest file in that directory (once there are 10 files), but you may want to use the ifExists block to reduce unnecessary activity.

Great @TIMAI2

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.