January 13th, 2013, 12:28 PM
Can't show image on webpage.
I use the TCPServer with "ClientSocket.SendIn" commands to build a webpage with text. This works great and I can now surf to the computer running my program and see the data.
ClientSocket.Sendln('<p><b><span style=color:silver>24h:</span></b> '+Label2.Caption+' </p>');
Now to the problem. My program generates images (gif, jpg, png) of charts in the same directory as the program it self. I would like to present these images on the webpage as well, but this seems to be very difficult.
It doesen't matter how I define the path to the file and the file name, the browser won't show the image. It only shows just an image icon and the name of the image. Observe that it's not an "broken link" icon.
So even if I define a correct path to the image, the browser won't show it. I have tried all variants of HTML code with out any luck so far.
Is the TCPServer unable to open and use local files?
Any one that have any idea about this?
January 14th, 2013, 12:11 AM
Does the program handle image querying? The way web browser works is after receive html document, it will ask the web server of each image (specified in that image src) for the content of the image. I think your program only sends out html codes but not handle incoming image content query.
Last edited by Luthfi; January 14th, 2013 at 12:14 AM.
January 14th, 2013, 02:00 AM
I think you are right, there is not any image handling added or configured so that makes sense.
Can that easily be done or is it a huge work to apply that?
January 15th, 2013, 12:52 AM
I believe it's can be done easily. Unfortunately the last time I worked with similar thing like this was years ago. So can not give you immediate sample codes. But you can peek into source of TIdHttpServer and study how it handles request of binary document/file (which what images are).
January 15th, 2013, 05:32 AM
Thanks, I will look around and see if I can find something. I'm not an expert in any way so I appreciate a lot all help I can get.
January 15th, 2013, 06:40 AM
On second thought, instead of using TidTCPServer, why don't you just use TIdHttpServer? It already capable of handling image querying. And sending out html codes were already its main job. Since TIdHttpServer was a descendant of TIdTCPServer, it got most (if not all) functionalities of TIdTCPServer.
January 15th, 2013, 08:44 AM
That's a very good idea, I guess that it is not the same "ClientSocket.Sendln" code for the HTML?
Today I send the text "OnExecute" with the TCPServer but that event seems not present in TIdHTTPServer.