473,396 Members | 1,779 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Dyanmic Images Reload

I have a php script that dynamically creates images, reusing image files on
the server to save space and clutter.

The problem is described in the steps below:

1. User clicks on a button.
2. Same page loads, but the php script creates a new image in an old file.
3. It displays the image file, but the old image shows, even though the file
contains the new image.

My options are:

1. Use javascript to force a reload when the user clicks the button (not
desirable, because the user is forced to confirm the reload by the browser).
2. Put a cheesy blurb on the page telling the user to reload or refresh
(along with ideotic explanations of how to do it).
3. Some really great way someone here is going to describe to me (my
preference).

Rex
Jul 17 '05 #1
4 2474

STEPHEN GOODE wrote:
3. Some really great way someone here is going to describe to me (my
preference).


Add a 'please don't cache me' header to the script creating the image
files. See http://www.php.net/manual/en/function.header.php

NB header() lines must all be issued before any other output is sent to
the browser (but you knew that already). Something along the lines of:

<?php
// a date in the past...
header( "Expires: Sat, 18 Mar 2000 00:00:01 GMT" );
// hint...
header( "Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . " GMT" );
// don't cache me...
header( "Cache-Control: no-cache, must-revalidate" );
// no, really...
header( "Pragma: no-cache" );
// it's a piccy...
header( "Content-type: image/jpeg" );
....
// rest of image code...

?>

---
Steve

Jul 17 '05 #2
Do you need to reload the whole page, or will refreshing the image be
enough?

Maybe just use js to reload only the image.

document.images["imgName"].src="getImage.php?blah="+escape(new
Date());

or something like that. Adding a fake querystring to your image src
will persuade the browser to refetch the image instead of using the
cached version. You might also experiment with adding "no-cache"
headers to your image when you serve it up.

Tim.
"STEPHEN GOODE" <re******@verizon.net> wrote in message
news:oXYxd.3602$hc7.1541@trnddc06...
I have a php script that dynamically creates images, reusing image
files on the server to save space and clutter.

The problem is described in the steps below:

1. User clicks on a button.
2. Same page loads, but the php script creates a new image in an old
file.
3. It displays the image file, but the old image shows, even though
the file contains the new image.

My options are:

1. Use javascript to force a reload when the user clicks the button
(not desirable, because the user is forced to confirm the reload by
the browser).
2. Put a cheesy blurb on the page telling the user to reload or
refresh (along with ideotic explanations of how to do it).
3. Some really great way someone here is going to describe to me (my
preference).

Rex

Jul 17 '05 #3
Steve,

Thanks. I couldn't get it to work. It all seemed to be working. I mean, the
header calls were all done right and before any other output, but it still
cached those images.

What worked was what Tim suggested in another reply. I'm still hoping to
figure out why the headers didn't work.

Thanks again.

Rex
Jul 17 '05 #4
Tim,

Thanks. That worked. Don't know why the no-cache stuff didn't work, but I
plan to figure it out.

Rex
Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Winfried Koenig | last post by:
Hi everyone, I have a main page: -------------------------------------------------- <html><head><title>Test</title> </head><body> <img id="img_a" name="img_a" src="image_1.png" alt=""><br>
4
by: STEPHEN GOODE | last post by:
I have a php script that dynamically creates images, reusing image files on the server to save space and clutter. The problem is described in the steps below: 1. User clicks on a button. 2....
4
by: Mark Allison | last post by:
Hi, Newbie here, please bear with me. I have a C# project which implements a tree view control. I want to add some images to this tree view control. The tree view control represents the tree...
2
by: JD | last post by:
Hello, I have webcams, and I want to display the images (jpg) from the cameras on a webpage, refreshed continuously. For a smooth transition I found a script that utilises double buffering....
2
by: Hellogeetu | last post by:
Hi All, I am creating dynamic controls but not on page_load event but on one of the button click event. I m able to get the controls value by using request.form but i m unable to handle the...
2
by: RB | last post by:
Hi there, I'm having a problem with an ASP.NET/VB.NET Control I am writing. The control is a simple gallery control, which shows a set of thumbnails (using a DataList), and a main image of the...
1
by: pupilstuff | last post by:
hi guys i wan to make dyanmic crystal report according to values which i checked from check box thats all i did 1. I made data set having data table name "Customer" 2 i put four columm id,name...
30
by: fuchsia555 | last post by:
Is there code to auto reload images if it doesn't load at first time in users browser ?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.