View Full Version : Refresh Image

10-25-2009, 08:10 PM
Hi, im not sure if you do this in Ajax or in php, im trying to make an image that refreshes like you see in some signatures, that update automaticlly.

So if someone is using the image on a different website the image will still update even though they are not present on the hosted website for it to be updated.

Is this possible?

10-25-2009, 08:45 PM
Yes and no, it depends on what you're meaning.
If its visual, and changes with time that passes, that is either a gif (or other animated image) or using ajax. PHP cannot refresh images - once processing is complete its job is done and cannot re-interact with an image.
If you mean data (something like: 'this image has been viewed x times') that is done by using PHP to actually create the image (either from direct drawing techniques, or more often from an already existing image source), and when accessed it simply increments / changes its text, updates a database or file storage, and then serves the php page as an image.
Note that most sites will require that an image based extension be used when using images. That assumes that they forum or cms or whatever isn't allowing direct html modification. The only way I know that can be used to handle that is to use htaccess and rewrite you're desired image extension to be served as php.

10-25-2009, 08:56 PM
No, im talking about a PHP script that creates the image as you explained but it stores that image on the server which can be linked to other websites/forums but the image created by the php script changes depending on certain variables. But i need it so that the image will update automatically, so if the image is used on a external site the image is still updated.

Is this possible?

10-25-2009, 09:20 PM
Then yes that can be done. The image itself is a PHP script, so it will always be attached to remotely. If its to be interpreted as an image, it can take care of any coding first and then display the image. Just remember what I said about most external sites requiring that you have an image based extension; this is pretty much a universal security enhancement, so you'll need to serve out images as php pages first and then as an image in case the file doesn't exist.