How to show image in WebImage on Gambas3

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

How to show image in WebImage on Gambas3

Post 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
User avatar
cogier
Site Admin
Posts: 1117
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: How to show image in WebImage on Gambas3

Post 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.
Herberth
Posts: 4
Joined: Saturday 24th April 2021 3:29pm

Re: How to show image in WebImage on Gambas3

Post by Herberth »

Thank you very much for answering, but your code does not work for me. :cry:
User avatar
PJBlack
Posts: 184
Joined: Tuesday 9th June 2020 10:26pm
Location: Florstadt, Hessen, Germany

Re: How to show image in WebImage on Gambas3

Post 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]
User avatar
BruceSteers
Posts: 1505
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: How to show image in WebImage on Gambas3

Post 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
If at first you don't succeed , try doing something differently.
BruceS
User avatar
stevedee
Posts: 518
Joined: Monday 20th March 2017 6:06pm

Re: How to show image in WebImage on Gambas3

Post 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.
Herberth
Posts: 4
Joined: Saturday 24th April 2021 3:29pm

Re: How to show image in WebImage on Gambas3

Post by Herberth »

Thank you very much for your suggestions.
but it was not functional for me
User avatar
Quincunxian
Posts: 171
Joined: Sunday 25th June 2017 12:14am
Location: Western Australia

Re: How to show image in WebImage on Gambas3

Post by Quincunxian »

I've been playing with this over the the last few weeks.
Writing the path so: <img source='file:///[path to image].image.png'> stopped working.
I think that this may be a security thing but it's hard to be sure.

The solution I found that works is placing the images to be displayed in a folder structure like so:
MyWeb
|--WebPages
|--Images
Any web page in in the structure can then use <img src='../Images/image.png'>
This is the only way I could get images to display at all in local web pages.

The last time the normal 'file:///' method worked was about 2 months(?) ago.
Cheers - Quin.
I code therefore I am
Post Reply