#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Location
    Sweden
    Posts
    4
    Rep Power
    0

    Can't show image on webpage.


    Hi all,

    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.

    Ex.
    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?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2012
    Posts
    156
    Rep Power
    3
    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.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Location
    Sweden
    Posts
    4
    Rep Power
    0
    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?
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2012
    Posts
    156
    Rep Power
    3
    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).
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Location
    Sweden
    Posts
    4
    Rep Power
    0
    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.
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2012
    Posts
    156
    Rep Power
    3
    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.
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Location
    Sweden
    Posts
    4
    Rep Power
    0
    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.

IMN logo majestic logo threadwatch logo seochat tools logo