galvin Posted December 28, 2008 Share Posted December 28, 2008 Hi guys, I have code where users create images that are always named the same thing. For example, if they create an image and save it, it's called "image1.jpg". If they then edit that image and re-save it, it's still called "image1.jpg." This has led to problems (mainly with IE, but also to a lesser degree with Firefox) where the user resaves edits to the image but it still shows an earlier version of the image when displayed in the browser. I have tried cache-clearing functions (with the help of guys on this site) but they are not helping. So I think the bottom line is that I should have the files be uniquely renamed to prevent this problem. I won't bore you with my code, but in a nutshell, they can edit the picture and hit "Save" and then they can go back and "edit" the picture and then they would hit a "Re-Save" button. Is there some way to have a variable (i'll call it $take) that increases by 1 (or goes up by one letter) each time the "Re-Save" button is pushed? For example, the user creates the orignal image and hits Save. The file is called "image1.jpg" They then edit the image and hit "Re-Save" and the file then gets called "image1a.jpg" Then if they edit it again and "re-save", the file gets called "image1b.jpg" and so on. So I was thinking where I name the file, it could say {"images/image1" . $take . ".jpg"} where $take would somehow change with each new click of "Re-Save" Assuming that makes sense (which it probably doesnt ) does anyone know of an easy way to do this type of thing? And now that I think about it, I probably don't even need the $take variable to keep going "up". It could just alternate between two things (like "a" then "b" then back to "a" and so on) and that would suffice. Any thoughts would be greatly appreciated. Thanks, Greg Link to comment https://forums.phpfreaks.com/topic/138652-create-an-alternating-variable/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.