Page 1 of 1

How to show image in WebImage on Gambas3

Posted: Saturday 24th April 2021 4:03pm
by Herberth
Hi

I need to display an image (webimage) that is not in my project's public folder.

I know that if my image it is in my project the code would be:

WebImage1.Image = "linux.png"

By my image the path is absolute

WebImage1.Image = "/home/user/linux.png"

How can I display an image in a webimage with absolute path ..?

Thanks

Re: How to show image in WebImage on Gambas3

Posted: Sunday 25th April 2021 8:47am
by cogier
Hi Herberth, and welcome to the forum.

Your problem is easily fixed with: -
WebImage1.Image = User.Home &/ "linux.png"
Note the use of the &/ command that sorts out if you need (or don't need) a '/' added to the path.

Re: How to show image in WebImage on Gambas3

Posted: Wednesday 28th April 2021 3:32pm
by Herberth
Thank you very much for answering, but your code does not work for me. :cry:

Re: How to show image in WebImage on Gambas3

Posted: Wednesday 28th April 2021 4:28pm
by PJBlack
when i read the post for the first time, a keyword spontaneously came to my mind: cross site scripting ... so i would not be sure that the access outside the document root is possible ... but i don't know exactly. :(

maybe you have to copy/move the image file manually via shell/exec into a folder inside and then access it with a relative path

but if charlie or steve (bruce has unfortunately become exceptionally quiet) have no ideas this is generally a very bad sign ...

[DeepL is my friend]

Re: How to show image in WebImage on Gambas3

Posted: Wednesday 28th April 2021 7:59pm
by BruceSteers
PJBlack wrote:
Wednesday 28th April 2021 4:28pm

but if charlie or steve (bruce has unfortunately become exceptionally quiet) have no ideas this is generally a very bad sign ...

[DeepL is my friend]
I've not been coding much so nothing to show but still here and there helping where I can :)

I know almost nothing about using the web components though so not had much to input on this , i'll say my 2 bits worth...

It looked to me like it made it's own virtual server , i'm not so sure reaching outside via the filesystem is possible.

could it be done with a socket?
maybe a gambas desktop app listening on a socket could send the files in a more http way via a request from the gambas web app?
Gambas web works very different to normal gambas.
Or if you are running an apache server you could manage access to local folders that way

Re: How to show image in WebImage on Gambas3

Posted: Thursday 29th April 2021 6:34am
by stevedee
BruceSteers wrote:
Wednesday 28th April 2021 7:59pm
...I've not been coding much so nothing to show but still here and there helping where I can...
Me too...
...and when I'm allowed to play by "The Boss" I'm currently spending 95% of any play-time trying to 'tame' my 3D printer!

I also know nothing about this component, and when you look at the Help for Webimage.Image it just says: "This symbol does not exist."

I know the Devs are not keen on people using absolute addressing, so maybe its coded that way.

However, you could try to grab the image and then pass it on. Maybe something like:-
Dim imgTarget As Image

  imgTarget = Image.Load("/home/steve/test.jpg")
  WebImage.Image = imgTarget
...but I haven't tested this, its just another "over breakfast" idea.