Here's the code for the page...

<?php
// this is the path of your files folder. Change 'pathofile'
$dir = "images/";
// this takes the files in the directory and puts them in an array
$array = array();
$handle = opendir($dir);
$extensoes = array("jpg", "png", "jpeg", "gif");

while ($file = readdir($handle))
{
 for ($i = 0; $i < count($extensoes); $i++)
 {
  if (eregi("\.". $extensoes[$i] ."$", $file))
  {
   $array[] = $file;
  }
 }
}

closedir($handle);
sort($array);
reset($array);

// takes the objects in the array and randomizes them
$arrayobj = array_rand($array);
$random = $array[$arrayobj];
// this creates the path name to the random file
// $path becomes the path name (duh) for the file
$path = $dir . $random;

$width = imagesx($random)/4;
$height = imagesy($random)/4;

// this is set up as an <img> tag and will show a random image
print "<img src=\"$path\" height=\"$height\" width=\"$width\">\n";
?>

--
Robert Sossomon, Business and Technology Application Technician
4-H Youth Development Department
200 Ricks Hall, Campus Box 7606
N.C. State University
Raleigh NC 27695-7606
Phone: 919/515-8474
Fax:   919/515-7812
[EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to