PHP/refresh image problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tpra21
Forum Newbie
Posts: 22
Joined: Wed Jul 20, 2005 6:20 pm

PHP/refresh image problem

Post by tpra21 »

I have a form where people can post a housing ad with two pictures. If the user posts two pictures, and then you view there ad, the pics display fine. But, if the user edits/overwrites those pictures (using an edit-ad form) with different ones, the new pictures won't display until the user hits the refresh button on their browser.

I am using a MySQL db to store the path of the images and then copying the actual uploaded images into a folder called "uploads." I then display the image using an <img> tag with the image path.

I know it sounds confusing, but basically it is as follows:

1.) The first image the user has is called 1_01.jpg.

2.) The user then decides to upload a different image to replace the above image.

3.) The new image is also called 1_01.jpg, but when you go to view the new image, you still see the old one, until you hit refresh on your browser. At that point, the new pic displays.

I know it sounds like a memory problem, but I have tried everything to get the old photo out of memory.I have tried refreshing using PHP, HTML, and so on and have had no luck. I also tried to use the HTML META NO-CACHE tag with no luck, any help would be greatly appreciated!

Thanks, Adam
nyy2000
Forum Newbie
Posts: 15
Joined: Tue Jul 12, 2005 12:40 am

Post by nyy2000 »

What will happen if you try:

Code: Select all

header("Cache-Control: no-store, no-cache, must-revalidate");
tpra21
Forum Newbie
Posts: 22
Joined: Wed Jul 20, 2005 6:20 pm

Post by tpra21 »

I placed that in my code (in my header.php file that I include in all files), and I have an interesting result. In Netscape (version 7), my problem is fixed, the new pictures display fine. So, I now know that the problem is directly related to Internet Explorer. Thanks for the input, but I don't believe it helped for my problem, but I will leave the code in my files anyway. If you have any other suggestions, please throw them my way.

Thanks again,
nyy2000
Forum Newbie
Posts: 15
Joined: Tue Jul 12, 2005 12:40 am

Post by nyy2000 »

Okay, how about placing these tags right after the end of body tag like this?
(Better to put the same tags in the header section as well)

Code: Select all

</BODY>
<HEAD>
<META HTTP-EQUIV=&quote;Pragma&quote; CONTENT=&quote;no-cache&quote;>
<META HTTP-EQUIV=&quote;Expires&quote; CONTENT=&quote;-1&quote;>
</HEAD>
</HTML>
tpra21
Forum Newbie
Posts: 22
Joined: Wed Jul 20, 2005 6:20 pm

Post by tpra21 »

I put that in my code, and nothing.... I have tried that one before. My site is at http://www.wcorentals.com if you want to experience the problem first hand. If you create an account, post an ad with pictures, and then edit your ad with new pics you'll see the problem (in IE). I also thought those tags would work, but darn I've got something screwed up.

Where exactly should the "header" tag go? At the very beginning before my include statements, or after the <html> tag, etc...

Thanks a lot for your help!
tpra21
Forum Newbie
Posts: 22
Joined: Wed Jul 20, 2005 6:20 pm

Post by tpra21 »

FIXED!! My Internet Explorer 5 browser was set to check for new pages (refresh) every time the browser was opened, not everytime a new page is loaded. I changed, and it works!! Amen, and thanks to nyy2000 for your help bud!

Thanks,
nyy2000
Forum Newbie
Posts: 15
Joined: Tue Jul 12, 2005 12:40 am

Post by nyy2000 »

Yes, that would work. But the thing is you would need to force users to change the Internet Explorer setting manually.
I registered and put sample image at your website, and I saw the problem.

What I meant by header section is right after the head tag.
Post Reply