Random Image Generator

This is a very simple php script that will display randomly generate image when the script is called
this is entirely file based and there for should run on any php enabled web hosting.
Please read the in script notes about what files to use.


// For this script all images must be in .jpg format with a .jpg extension and numbered in ascending order
// Images range to display
// images can start and end at any number but the numbers must be consecutive,
$r_img = rand(1,10);
// Relative path of where script is executed to where images are stored
$addpic = “./randompics/”. $r_img .”.jpg”;
$handle = fopen($addpic, “rb”);
$img = fread($handle, filesize($addpic));
$type = “jpg”;
$img = imagecreatefromstring($img);
if ($img != false)
switch ($type){
case “jpg”:
header(“Content-Type: image/jpeg”);



save it as “myimagescript.php”

upload it to your php enabled webserver

then upload 10 .jpg images to folder /randompics/

Script In Action

Image Script In Action

Image Script In Action

Author : Capt.Crash