![]() |
Random image script - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Random image script (/showthread.php?tid=6087) |
Random image script - El Forum - 02-14-2008 [eluser]Joe_Archer[/eluser] Hi, I'm fairly well versed with CI and have been using it for around a year, successfully, both inside and outside of work. As a little side project I'd like to produce a random image script which when called, selects an image from a folder at random and returns it to the browser. I don't have a problem writing the code to do this, it's very straight forward, what I'm not sure about though, is how to return "just an image" to the browser. I don't want to output any HTML, I just want to return an image file as though the file had been browsed to directly on the server. I assume I'll need to set a mime type/header to do this, but I'm not sure how I'd go about doing so. Any help greatly appreciated. Random image script - El Forum - 02-14-2008 [eluser]xwero[/eluser] you need to write an independent script for this to work. Code: <?php ![]() To make a helper function out of this you do as follows Code: function random_image($path) Random image script - El Forum - 02-14-2008 [eluser]Joe_Archer[/eluser] ok thanks, that makes sense. much appreciated. Random image script - El Forum - 02-14-2008 [eluser]Joe_Archer[/eluser] I ended up doing it thus: Code: <?php I didn't need any independent scripts in the end. |