Full-Demon Posted December 29, 2007 Share Posted December 29, 2007 Hi, I have a script where I have to load a certain image and than output the image, but I don't want it that the server has to upload the image and than let the user download: I want the user to just download from the original fileserver (where the image is stored). So I have: File server (images stored here) -> Script server (with the actual script) -> User Users use the image tag to load the image: <img src="site.com/myscript.php"> I thought about this for my script: <?php $array = array('img1.png', 'img2.png'); header("Location: othersite.com/".$array[rand(0, 1)]); ?> That works, except that it is not random! The output is always one image and if you reload it never switches to the other one! How can I make this like I want? Thank you a lot! FD Link to comment https://forums.phpfreaks.com/topic/83627-solved-load-and-output-image-without-uploading-bandwidth-spending/ Share on other sites More sharing options...
MadTechie Posted December 29, 2007 Share Posted December 29, 2007 this should work.. <?php $array = array('img1.png', 'img2.png'); $rand = array_rand($array); header("Location: othersite.com/".$array[$rand]); ?> but then again yours looks fine as well... Link to comment https://forums.phpfreaks.com/topic/83627-solved-load-and-output-image-without-uploading-bandwidth-spending/#findComment-425437 Share on other sites More sharing options...
Full-Demon Posted December 29, 2007 Author Share Posted December 29, 2007 Thanks for the reply, but it still doesn;t work. It looks like the client/browser doesn't reload the image...I even tried it with the no-cashing headers, but neither works. How can I force the client to reload the image? Link to comment https://forums.phpfreaks.com/topic/83627-solved-load-and-output-image-without-uploading-bandwidth-spending/#findComment-425454 Share on other sites More sharing options...
MadTechie Posted December 29, 2007 Share Posted December 29, 2007 erm.. maybe <?php header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past $array = array('img1.png', 'img2.png'); $rand = array_rand($array); header("Location: othersite.com/".$array[$rand]."?Rand=".time()); ?> depends how your calling that page itself.. Link to comment https://forums.phpfreaks.com/topic/83627-solved-load-and-output-image-without-uploading-bandwidth-spending/#findComment-425463 Share on other sites More sharing options...
Full-Demon Posted January 2, 2008 Author Share Posted January 2, 2008 Ah that worked! Thanks a lot Link to comment https://forums.phpfreaks.com/topic/83627-solved-load-and-output-image-without-uploading-bandwidth-spending/#findComment-428139 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.