How to show image in WebImage on Gambas3

For questions about Gambas web tools.
Post Reply
Herberth
Posts: 2
Joined: Saturday 24th April 2021 3:29pm

How to show image in WebImage on Gambas3

Post by Herberth » Saturday 24th April 2021 4:03pm

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

User avatar
cogier
Site Admin
Posts: 689
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: How to show image in WebImage on Gambas3

Post by cogier » Sunday 25th April 2021 8:47am

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.

Herberth
Posts: 2
Joined: Saturday 24th April 2021 3:29pm

Re: How to show image in WebImage on Gambas3

Post by Herberth » Wednesday 28th April 2021 3:32pm

Thank you very much for answering, but your code does not work for me. :cry:

User avatar
PJBlack
Posts: 131
Joined: Tuesday 09th June 2020 10:26pm
Location: Florstadt, Hessen, Germany

Re: How to show image in WebImage on Gambas3

Post by PJBlack » Wednesday 28th April 2021 4:28pm

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]

User avatar
BruceSteers
Posts: 470
Joined: Thursday 23rd July 2020 5:20pm

Re: How to show image in WebImage on Gambas3

Post by BruceSteers » Wednesday 28th April 2021 7:59pm

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
Wishing well
Bruce

If at first you don't succeed , try it differently.

User avatar
stevedee
Posts: 427
Joined: Monday 20th March 2017 6:06pm

Re: How to show image in WebImage on Gambas3

Post by stevedee » Thursday 29th April 2021 6:34am

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.

Post Reply