Hello, I have this script that runs fine on my windows install but it is not running on my Ubuntu install. Heres the code
$root = $_SERVER['DOCUMENT_ROOT'];
$path = '/wordpress/...'; //correct Path being used
function getImagesFromDir($path) {
$images = array();
if ( $img_dir = @opendir($path) ) {
while ( false !== ($img_file = readdir($img_dir)) ) {
// checks for gif, jpg, png
if ( preg_match("/(\.gif|\.jpg|\.png)$/", $img_file) ) {
$images[] = $img_file;
}
}
closedir($img_dir);
}
return $images;
}
function getRandomFromArray($ar) {
$num = array_rand($ar);
return $ar[$num];
}
// Obtain list of images from directory
$imgList = getImagesFromDir($root . $path);
then this to display
<div style="height: 50px; position: absolute; top: 84px; left: 66px;" class="cycle-slideshow2">
<?php
foreach ( $imgList as $img ) :
$img = getRandomFromArray ( $imgList );
?>
<img src="<?php echo $path . $img ?>" width="27" height="27" />
<?php endforeach; ?>
</div>
It does not seem to pull the $img out of the code and im not sure why.