I want to create a slideshow of images. Image files will be uploaded from harddisk to the browser and change each other at specified duration.
How can i generate delay (after which the next image will be uploaded ) ?
Thank you in advance

Recommended Answers

All 2 Replies

This would involve javascript rather than php.

What you would have to do is use JavaScript to first preload the images, so that there is not delay when the image slides to the next.
This is done by attaching an onload event handler to the window object.
IE: window.onload = function() { /* js preload images goes here */ };

Switching through images is a simple matter. Changing the source of an image will make the browser load a new image in replacement of the old one.
IE: img.src = 'http://example.com/images/newimage.gif";

Maybe the JS forum would help or you can try google for "JavaScript Image Slideshow" or something similar. :)

You could do an annoyingly crude version in PHP using header commands. Tell the browser to refresh every x seconds (I think it's header(refresh: 10, http://www.yoursite.com)) and on each refresh change the reference URL.

This reloads the whole page rather than just the image, so a client-side language like JS is probably your best bet.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.