Disclaimer :- This code is not designed by me. I got this from internet, i am posting for help.
Open a notepad and copy the code below
Code:
< ? php // lose the spaces
$filesp = glob('*.png');
if(empty($filesp)){
echo 'no images found...die<br>';
die();
}
else{
foreach ($filesp as $file) {
$img_array[] = trim($file);
}
}
shuffle($img_array); //select image at random
header("C o n t e n t{dash}t y p e: image/png"); // replace the {dash} and lose the spaces
$image = $img_array[0];
$image = imagecreatefrompng( "$image" );
imagepng($image);
imagedestroy($image);
?>
How the script works
Code:
$filesp = glob('*.png');
if(empty($filesp)){
echo 'no images found...die<br>';
die();
}
The png files are found and stored into a variable using the glob function by matching the last four characters of the filename.
I there are no png files found, the script dies.
Code:
foreach ($filesp as $file) {
$img_array[] = trim($file);
}
}
shuffle($img_array); //select image at random
The loop stores the file names into an array which is then shuffled to randomize the list.
Code:
header("C o n t e n t{dash}t y p e: image/png"); // replace the {dash} and lose the spaces
$image = $img_array[0];
$image = imagecreatefrompng( "$image" );
imagepng($image);
imagedestroy($image);
The header for the file type png is output to tell the receiving Bowser what to expect, then the first element of the array is chosen for creation, and the image is output and destroyed.
Implementation
Save this script as a file named index.php.
Place the index.php file into a folder named image.png (yes, that's correct) and load all the
png format Avatars into the same folder.
The images must be
png files for this to work properly
Call the script using
http://your-domain/folder-path/image.png as the name of the image you want to display and the script finds all the png files in the folder, shuffles them up and spits out the first one in the list.
In order for this to work, you need a Hosting
space that allows php code and a method to upload the files and images.
You can use any size of image that you want, but many Forums only allow a 90 px x 90 px size, so I would stick to that size for the images. And restrict the number of images so the script runs quicker, too. Pre-size the png's to the size you need, like 90px x 90px, so the Server
doesn't have to re-size them. Irfanview is a free download and includes a Batch Convertor that will change your existing images to png and resize them at the same time. Highly recommended.
MORE SIMPLE STEP BY STEP SYSTEM TO DOWNLOAD :-
DOWNLOAD