kev wood Posted May 8, 2008 Share Posted May 8, 2008 i am having a problem with old images showing up on a web site as they are being displayed from the cache i have tried meta data tags to stop this it didnt work and php headers which also didnt work. i am now looking at storing the images with a random number attached to them. as the number that is attached to them is random when i come to display the image again on a different way what is the best way to get the number across to the next page. i have tried session_start() but it does not like some of the code in the website and start to throw up loads of errors with code that is working fine without it. if i was to to use a form to post the data should my code look like this code for random number $rand= rand (1, 100); submit button: <form name="newad" method="post" enctype="multipart/form-data" action=""> <input type="hidden" method="post" name="rand" /> <input type="file" name="broad1_image" ></td></tr> <input name="Submit" type="submit" id="image1" value="Upload image" ></td></tr> </form> to retrieve value of rand $rand=$_POST['rand'] Link to comment https://forums.phpfreaks.com/topic/104718-storing-images-with-a-random-number/ Share on other sites More sharing options...
The Little Guy Posted May 8, 2008 Share Posted May 8, 2008 Why is method="post" here: <input type="hidden" method="post" name="rand" /> you should change it to this im guessing <?php $rand= rand (1, 100); ?> <input type="hidden" value="<?=$rand;?>" name="rand" /> Link to comment https://forums.phpfreaks.com/topic/104718-storing-images-with-a-random-number/#findComment-535974 Share on other sites More sharing options...
discomatt Posted May 8, 2008 Share Posted May 8, 2008 Is the issue isolated? Or is it happening on many different machines? I don't believe your current fix is the best way to do it. Link to comment https://forums.phpfreaks.com/topic/104718-storing-images-with-a-random-number/#findComment-535977 Share on other sites More sharing options...
kev wood Posted May 8, 2008 Author Share Posted May 8, 2008 i have changed that code so it looks like what yo have posted put when i try to display the image nothing shows. so i echoed out the $rand and it gave me no value. so it is either not passing the data to my send.php page or i am trying to retrieve the data in the wrong way. i am trying to retrieve the data with $rand=$_POST['rand']; Link to comment https://forums.phpfreaks.com/topic/104718-storing-images-with-a-random-number/#findComment-535986 Share on other sites More sharing options...
kev wood Posted May 8, 2008 Author Share Posted May 8, 2008 discomatt what would you do to complete this task? i am defo open to suggestions this is now giving me a headache. silly cahce Link to comment https://forums.phpfreaks.com/topic/104718-storing-images-with-a-random-number/#findComment-535993 Share on other sites More sharing options...
discomatt Posted May 8, 2008 Share Posted May 8, 2008 As i said, is the problem isolated or not? Also, different browsers like to have different 'no-cache' headers. Try this snippet header("Expires: Tue, 03 Jul 2001 06:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); Link to comment https://forums.phpfreaks.com/topic/104718-storing-images-with-a-random-number/#findComment-536010 Share on other sites More sharing options...
kev wood Posted May 9, 2008 Author Share Posted May 9, 2008 sorry dicomatt it took so long to get back i have been working with a group of kids all day trying to get them to design a magazine which was not fun. i have tried those headers and they didnt work. i put them on every page that had anything to do with the images even if they was not displayed on them and they are still showing the old images. i think the only way i will get this to work is with a random number attached to the image, but that gives me the problem of passing the variable on to that page. the code just dont like me. i have successfully used the post function before but only to post user names and simple strings around websites i have never used it to pass a random number before. i thought it would be simple to code but oh how i was wrong. either that or i have forgotten how it is done and i am just messing it up with the code. the code i am using looks like this <form name="newad" method="post" enctype="multipart/form-data" action=""> <input type="hidden" value="<?=$rand;?>" name="rand" /> <input type="file" name="broad1_image" ></td></tr> <input name="Submit" type="submit" id="image1" value="Upload image" ></td></tr> </form> and to retrieve the variable on the next page i have tried writing this code both ways $_POST['rand']=$rand; $rand=$_POST['rand']; still with no joy Link to comment https://forums.phpfreaks.com/topic/104718-storing-images-with-a-random-number/#findComment-536760 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.