0

I am writting a G-WAN application, which will count the number of visit for different images (the images are stored on different servers).

HTML code:

<img src = "http://example.com/?sendandcount"></img>

For the sendandcount application, after I count and record the visitor detail, I try to return an image URL like "http://abc.com/test.jpg", but it doesn't work! The "img src" tag seems to request and identify the image content only...

Do I need to get all the images from other servers first and delivery under from the gwan server? (It will cause inconsistencies as these images will change as time goes...)

Any suggestion? Thank you very much!

Gil
  • 3,279
  • 1
  • 15
  • 25
moriya
  • 75
  • 9

1 Answers1

3

You can't send a string back. You need to send the image itself. When the IMG tag source is looked up by a browser, the browser expects to receive back a file.

The easiest way to do this from your application is by a URL redirection.

Otherwise, you'd have to output the relevant MIME headers and send the file data yourself. This is only necessary if you're doing things like dynamically watermarking or resizing an image, or if the image is not publicly available.

Community
  • 1
  • 1
paddy
  • 60,864
  • 6
  • 61
  • 103
  • I have successfully using redirect method which gwan provide, however, it took quite a long time to wait before display the image, what should I do to improve it ? thanks! – moriya Jul 09 '13 at 08:54
  • 2
    The G-WAN redirection is instantaneous but then the client has to fire another DNS and HTTP request to your other server (where the images are stored), and this is what takes time. Solutions: use the same DNS name as used by G-WAN (to skip a DNS lookup), serve the image from G-WAN, etc. It's all about *network* latency here. – Gil Jul 09 '13 at 13:15