2

Is there a way to update a picture live and dynamically? Let me explain:

There is an application that uploads a picture in a various amount of time. At the moment, my script just ask every 5seconds for a new picture on the server but thats kinda old school and not a very good solution. So my question: Is it possible to detect a new picture on the server and show it immediately on the page?

The problem with regulary requests (every 5seconds) is that if the picture is loaded after a request it takes like 10seconds to update and thats a bit too long. And to make a request every second is quite a bad idea.

James Montagne
  • 73,502
  • 13
  • 107
  • 127
sanoi
  • 21
  • 2

1 Answers1

0

You will need server side push technology (also known as Comet) to do this. The exact implementation is really dependent on the server-side programming language you are using.

Edit:

A quick search on stackoverflow on 'Comet' gives a lot of additional info (also specific to certain programming languages): https://stackoverflow.com/search?q=comet

Community
  • 1
  • 1
Joris
  • 3,200
  • 2
  • 19
  • 18
  • thanks :) With server-side programming language one would you recommend? Do you think php will do it? – sanoi Feb 24 '12 at 18:34
  • @sanoi, it should do it. Consider: http://www.zeitoun.net/articles/comet_and_php/start – Pateman Feb 24 '12 at 18:36
  • Although solutions with PHP are possible, it might not be the best choice (see http://stackoverflow.com/questions/603201/using-comet-with-php). While they have very interesting use-cases, server-side push applications are still rather complex to implement today. If you really want to use this (instead of polling), you must be prepared to spend some time on the topic. – Joris Feb 24 '12 at 18:37
  • with one would you think is the best choice? thanks to you all! – sanoi Feb 24 '12 at 18:39
  • Personally, it all depends on what you want to achieve. You can do this with PHP, but there might be better alternatives for you. Just check out the links posted and you should know what's best for you. :) – Pateman Feb 24 '12 at 18:41